a as an array and find the running max:
a =: 3 1 4 1 5 9 2
3 3 4 4 5 9 9
Then I want to filter out duplicates. I know that nub (
~.) does this, so I try:
~. >./\ a
3 4 5 9
It works but I don't know why. I thought it should not work.
\ are adverbs, so
(>./\) is a verb. We then have:
f g y, which is a hook, and it should be executed as
y f (g y). Obviously it does not work that way.
Instead, it's executed as
~. (>./\) (i.e.
f (g y)), like it was
~. @ (>./\). So what's going on here?
J executes statements right to left so your
~. >./\ a is equivalent to:
~. (((>./) \) a)
It would be a hook if it was parenthesized like:
(~. ((>./) \)) a
Some relevant discussions: function composition and how to take the train.
Edit: To make this clearer,
f g y is always
f (g y). If you want the hook, you have to write
(f g) y.