I define a as an array and find the running max:
a =: 3 1 4 1 5 9 2
>./\ a
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. / and \ 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?
Thanks.
J executes statements right to left so your
~. >./\ ais equivalent to:It would be a hook if it was parenthesized like:
Some relevant discussions: function composition and how to take the train.
Edit: To make this clearer,
f g yis alwaysf (g y). If you want the hook, you have to write(f g) y.