2+3 5 2 + 3 5 2 + 3 5
Most examples in this book have spaces around all primitives. This makes the individual words stand out and allows you to concentrate on the meaning of the words without the additional problem of first figuring out what the words are.
However, most J programmers, as they become more experienced, reach a point where they can easily read the words in a sentence, and the extra spaces become a nuisance and hindrance to understanding, rather than an aid. You will notice that in some of the later examples that some of these unnecessary spaces are left out.
There are some cases where a space is essential.
A space must separate names.
a=.3 plus=.+ a plus a 6 aplusa |value error: aplusa
The . (dot) and : (colon), used as inflections, change the word immediately in front of them into a new word. When used as a primitive or as the start of a primitive, they must have a space in front so that they are not treated as an inflection.
;: 'a . b' NB. 3 words +-+-+-+ |a|.|b| +-+-+-+ ;: 'a .b' NB. same 3 words +-+-+-+ |a|.|b| +-+-+-+ ;: 'a. b' NB. 2 words +--+-+ |a.|b| +--+-+
A space must separate a . or : , that is not being used as an inflection, from the previous word.
Numbers, for example 1e7, can contain letters. There are in fact several letters that can be used in spelling numbers in J. Letters that immediately follow a number are treated as part of the spelling of the number.
plus =. + 1plus 3 |ill-formed number | 1plus 3 | ^ 1 plus 3 4
|Primer Index Hover to reveal titles - Click to access -|