Q: What's the most common cause of blindness among J programmers?
A: Conjunctivitis.
In the early weeks, complex tacit definitions are torturous to write and next-to-impossible to read; blurred vision and sleepless nights are the occupational hazard of the programmer who dives into tacit J. If a co-worker is banging into doors as he stumbles to refill his tankard of coffee, here's how to check him out: hold up three fingers and ask him how many he sees. If he says "three", he's merely fallen in love or is working to a deadline, and he will recover. But if he replies "I see a list of 3 items each of which is a finger", you can expect to start receiving emails that look like they've been encrypted.
You can offer as a temporary palliative J's mechanism for converting an explicit definition to a tacit one. You request the conversion by using a left operand to : in the range 11 to 13 instead of 1 to 4 .
9!:3 (5) NB. Do this once to select simplified display
3 : 'x. - y.'
3 : 'x.-y.'
We defined a verb, and since we didn't assign it to anything, we see its value, which is just what we defined it to be.
13 : 'x. - y.'
-
by using 13 instead of 3, we ask the interpreter to try to find a tacit equivalent, which it did.
Here is another way to define the verb enclose from the previous chapter:
13 : '(>{.x.) , y. , (>{:x.)'
([:
> [: {. [) , ] , [: > [: {: [
The interpreter likes to use [: in its tacit definitions. Note that you use 13 : to get an equivalent for both monadic and dyadic verbs; there is no 14 : .
I recommend that you use 13 : as your first choice for defining tacit verbs. It will find all tacit equivalents that can be generated systematically, and the explicit definition is much easier to read than a tacit definition. You will still have to use your tacit-definition skills for irregular cases, such as
13 : '+:^:x. y.'
4 : '+:^:x. y.'
If x. or y. is used as an operand to a conjunction, as in this example, the tacit converter is not going to be able to make a tacit equivalent. The result of 13 : is still a verb performing the requested function, but it is an explicit definition rather than a tacit one. Note that the interpreter saw that the definition contained a reference to x., so it made the verb a dyad.
2 (13 : '+:^:x. y.') 3
12
This verb applies monad +: to y., x. times. Knowing about u^:v, you might find the tacit equivalent +:@]^:[ :
2 (+:@]^:[) 3
12
Special Verb-Forms Used in Tacit Definitions
It is impossible for a tacitly-defined verb to route one of its operands to an operand of a modifier inside the verb. For example, if we want a verb to set element x of y to 0, we can try
13 : '0 x.} y.'
4 : '0 x.}y.'
but we see that the converter was unable to find a tacit form.
Some modifiers have exotic forms that circumvent this problem. One such is the adverb } which supports the form x value`selector`operand} y . This produces the same result as (x value y) (x selector y)} (x operand y) so we could write
a =. 13 : 'x. 0:`[`]} y.'
a
0:`[`]}
3 a 9 7 5 3 1
9 7 5 0 1
Other such forms are x m&v y and x u&n y which are equivalent to m&v^:x y and u&n^:x y respectively.