You are right that this is not a "tacit issue", but actually it's not an
"explicit" issue, either. Witness:
Y=:13
Y 2 $ 52 ? 52
|syntax error
| Y 2$52 ? 52
There's no constructed verbs here (neither tacit nor explicit, just sentences.
The difference is in how J lexs (identifies the
words of the sentence) and parses (interprets combinations of words). In the
original sentence, there are 5 words:
;:'13 2 $ 52 ? 52'
+----+-+--+-+--+
|13 2|$|52|?|52|
+----+-+--+-+--+
Note that the 13 and 2 are considered a single, indivisible word, containing
multiple values (its numbers), as 'indivisible' would
be considered a indivisible word containing multiple values (its letters). But
in the broken sentence, there are now 6 words:
;:'Y 2 $ 52 ? 52'
+-+-+-+--+-+--+
|Y|2|$|52|?|52|
+-+-+-+--+-+--+
Note that Y and 2 are considered separate words. Without getting deep into
parsing, I will say J has no rules for how to interpret
two juxtaposed nouns. That is, J doesn't know what to do with Y 2 for the same
reason it doesn't know what to do with (13) 2 or 13
(2) or (13) (2) or 'foo' 'bar' or a. a: or 'foo' a: 13 'bar' a. etc.
There are several reasons for this (no default interpretation of juxtaposed
nouns), but from a user's perspective, you may consider
that there are multiple ways of combining arrays in J, and J isn't so arrogant
as to assume it knows which one is best for you. So
J insists you tell it how you want your arrays combined, as in 13 , 2 or 13 ,:
2 or 13 ; 2. Oh, and note the , in 13 and 2 is
append, not ravel, and serves a purpose similar to the natural commas in this
English sentence (forming a list out of individual
items).
Regarding the other issues, I recommend you stick with explicit code until
you're comfortable with J. Then you can start playing
with tacit code (this includes learning how to translate explicit to tacit
using 13 : ).
By the way, to mention "x" in an explicit verb, the verb must be a dyad. A
monad only has one argument, named y. A dyad has two
arguments, y (the same as in the monad) and also x. The construction 3 : 'foo
y' creates a monad. It is identical to monad def
'foo y' (which form I suggest you use). If you want a dyad, you need to say
dyad def 'x foo y' . If you want an ambivalent verb,
which can take one argument or two, I suggest you use one of the forms monad
def 'foo y' : (dyad def 'x foo y') or shorter, verb
def ('foo y';':';'x foo y'). These have the same effect (for different
reasons). You can also use the multi-line define in
place of the single-line def . In that case, to separate the monad from the
dyad, use a single colon on a line all by itself.
Here is a common pattern in J code:
myVerb =: verb define
default_x =. ... NB. default for x since it hasn't been
specified by the user
default_x myVerb y
:
NB. Logic using x and y here
)
Hope this helps.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm