3 ms·
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)
by avmich 12y ago
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.
- Gravityloss 12y agoThat takes some time to digest, but I guess is absolutely crucial to be able to do anything with this language. Would you say that this is 90% of the reason it looks so uncomprehensible?
- avmich 12y agoNo, it's not absolutely critical. You can do a lot of your own programming without using hooks and forks. Your programs will be somewhat simpler - and whenever you need to use a variable in several places, you'll have to explicitly name it - but still. Incomprehensibility happens in part because all ASCII characters are used - so you have a lot of differently-looking symbols; because [ and { aren't paired with ] and }, and " isn't paired either; because you often have . and : as the second character of built-in entities, so you've got a lot of dots... APL used the symbols invented explicitly for those purposes, but the price - non-ASCII alphabet - was considered too high. So - no, I wouldn't say forks and hooks are the source of 90% of uncomprehensibility.
- tubular 12y agoA mite of pedantry: the J train (a b c d) is a hook with a fork on the right, and so dyadically acts like 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 http://www.jsoftware.com/jwiki/Essays/Hook%20Conjunction%3F
- avmich 12y agoYes, my mistake regarding 4-element dyadic train.