[x] u@v y [x] u@n y Atop Conjunction
Forms the composition (u@v) of verbs u and v .
The resulting verb is applied independently to each cell of the argument(s).
- Operand u is always executed monadically on the result of each application of v
- Operand v is executed either monadically or dyadically depending whether u@v has been called monadically or dyadically
If the right operand of @ is a noun n, it is equivalent to the constant verb (n"_) which ignores its arguments and produces the result n which in turn becomes the argument to u.
#@> 'Newton';'Einstein' 6 8 2 3 <@, 4 5 +-------+ |2 3 4 5| +-------+
The result of u@v is a tacit verb equivalent to [x] (u@:v)"v y
[x] is used to signify that the phrase holds good whether x is present or not.
Implement: f(g(x)) -- the mathematical composition of the two functions: f and g.
mean=: +/ % # cat=: ,&1"1 ]z=: i.2 3 NB. sample noun 0 1 2 3 4 5 cat z NB. appends 1 to each row of z 0 1 2 1 3 4 5 1 mean@cat z NB. mean of the ROWS of cat z 1 3.25 mean@cat b.0 NB. rank of (mean@cat) 1 1 1
But see Rank in a hurry: an insidious rank problem for how and when these different methods give different results.
1. Phrase (u@:v)"v means "apply v followed by u on each cell of the operand(s) independently". The rank of a cell is given by the rank of the verb v . The results from the cells are collected to produce the overall result of u@v .
Note: unlike At (@:), the rank of Atop (u@v) depends on the ranks of u and v.
2. The difference between At (u@:v) and Atop (u@v) is shown in the first two columns of the diagram below.
None at all, for the monads (u@v) and (u&v)
u&v y ↔ u v y u@v y ↔ u v y
But the dyads are different
x u&v y ↔ (v x) u (v y) x u@v y ↔ u x v y
According to the J Dictionary -- &: is equivalent to & except that the ranks of the resulting function are infinite; the relation is similar to that between @: and @
The J Dictionary's definition of [x] u@v y as equivalent to u [x] v y has caused much confusion, because the statement must be read in the context of the rank of v .
The precise definition is as above.