|
In J there are two special ways to combine functions which are written using special syntax. Namely, 1) when you want to calculate f(y, g(y)) , you write (f g) y - this is "hook" of one argument (monadic, in J terms) 2) when you want to calculate f(x, g(y)) , you write x (f g) y - this is "hook" of two arguments (dyadic) 3) when you want to calculate f(g(y), h(y)) , you write (g f h) y - this is monadic "fork" 4) when you need f(g(x, y), h(x, y)) , you use x (g f h) y - dyadic fork 5) when you have a train - say, (a b c d e) x - longer than 3 elements, then you consider rightmost 3 functions (functions are called verbs in J) as a single fork - say, f - and then consider (a b f) x . So (a b c d e) x is b(a(x), d(c(x), e(x))) If the train length is even, the last operation becomes hook - so x (a b c d) y is a(x, c(b(x, y), d(x, y))) You can express any computation as a sufficiently complex train. |
a(x, c(b(y), d(y)))
Roger himself has dismissed [0] hooks as an unfortunate result of J4's myriad train rules, made in the name of tacitable everything, which I lament because for some reason, tacit programming is just so much more satisfying than normally solving the problem.
[0]: http://www.jsoftware.com/jwiki/Essays/Hook%20Conjunction%3F