Question

I have read the answer at Best strategies for reading J code, but in my console, I am not seeing the box structure. My console has the original command returned.

Please help me with I have missed. Thank you.

Was it helpful?

Solution 2

You can use a representation like this:

f =: (+/) % #
5!:2 <'f'
┌─────┬─┬─┐
│┌─┬─┐│%│#│
││+│/││ │ │
│└─┴─┘│ │ │
└─────┴─┴─┘

or you can turn on the box representation by setting it's global parameter:

(9!:3) 2 
f
┌─────┬─┬─┐
│┌─┬─┐│%│#│
││+│/││ │ │
│└─┴─┘│ │ │
└─────┴─┴─┘

Boxed representation (9!:3) 2 was default in previous versions of J.

See also Learning J/Chapter 27

OTHER TIPS

@Eelvex correctly identifies the underlying mechanisms which control display of results in J. However, 5!:2 only applies to its argument, and (9!:3) 2 will last throughout the session, but be reset to linear display (i.e. the "original command" you're seeing) when you restart J or spin up a new session.

If you want this change to persist, you can configure the session manager with your preference. That way, every time you start a new J session, the display will default to boxed.

How to configure the IDE depends on which version of J you're running, and which frontend you're using. Below is a screenshot of how to configure J6, which currently has the largest install base (though it's been superceded by J7 and J8).

If you tell us which version of J and which frontend you're using, we can give you instructions specific to your environment. Otherwise, the general advice is to add the line (9!:3) 2 to your personal startup script.

J6 display configuration

Note also that other displays are available:

  • Linear: "original command returned"
  • Paren: similar, but command is fully parenthesized
  • Box: Shows structure of command
  • Tree: shows relationship between components of command

You can configure the session manager to display commands in one or more of these formats. Try selecting multiple checkboxes in the configuration dialog, or listing out several options in the argument to 9!:3, as in:

(9!:3) 5 2 NB. Linear followed by boxed

   +/ % #
+/ % #
+-----+-+-+
|+-+-+|%|#|
||+|/|| | |
|+-+-+| | |
+-----+-+-+

Finally, while these fancy display formats are useful when you're learning J, you're likely to find them less useful as your understanding of the language develops, and ultimately they may become distracting. That's why the default display is "linear", and most J developers end up using it, supplemented by the occasional analysis using 5!:2, 5!:4, or even userland tools like "map display"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top