I want to write this tacitly:
AA =: {{ (u v y) v y }}
For context, I tend to use it to *A*pply monad u *A*t at a location
specified by ambivalent verb v.
AT =: {{ m&{:: : (<@[ m} ]) }}
3 AT ;/i.10
3
_ (3 AT) ;/i.10
+-+-+-+-+-+-+-+-+-+-+
|0|1|2|_|4|5|6|7|8|9|
+-+-+-+-+-+-+-+-+-+-+
_: AA (3 AT) ;/i.10
+-+-+-+-+-+-+-+-+-+-+
|0|1|2|_|4|5|6|7|8|9|
+-+-+-+-+-+-+-+-+-+-+
My main question is "how do I write AA tacitly?", but I'd also like to
present my (incorrect) thinking here in hopes that someone can fix it. :)
I first translated it into a fork inside a direct definition, and that
works fine:
AA =: {{ ((u @: v) v ]) }}
_: AA (3 AT) ;/i.10
+-+-+-+-+-+-+-+-+-+-+
|0|1|2|_|4|5|6|7|8|9|
+-+-+-+-+-+-+-+-+-+-+
I then thought that replacing u => [. and v => ]. would let me remove the
double curlies, but clearly this is the wrong idea:
AA =: ([. @: ].) ]. ]
_: AA (3 AT) ;/i.10
+-+-+-+-+-+-+-+-+-+-+
|0|1|2|3|4|5|6|7|8|9|
+-+-+-+-+-+-+-+-+-+-+
I don't really understand what it's doing but I'm (mistakingly?) imagining
that it's a fork.
If it were a fork with ] on the right, I think I should be able to rewrite
it like so:
AA =: ].~ ([. @: ])
But this gives a syntax error.... Why?
So okay, if I just put ] back in on the left:
AA =: ] ].~ ([. @: ].)
_: AA (3 AT) ;/i.10
_
Clearly my idea that [. and ]. mean "tacit u and v" is wrong.
Can anyone help me correct my thinking?
Thanks!
-Michal
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm