An alternative is to create modifiers for each of your examples
take =: (*@[ * |@[ <. #@:]) {. ]
forfirst =: 2 : '(v }. ]) ,~^:(0 < #@[) [ u v take ]'
-@] forfirst (1) 1 2 3
_1 2 3
3 - forfirst (4) 1 2 3
2 1 0
there is a definition for the obverse of {. (though it seems useless, as the
core nature of obverse is to only see its argument instead of knowing about the
full context of operation under &.:)
{. b. _1
,:
A dyadic version of your underravel, (
underravel =: 1 : '$@] $ [ u ,@]'
2 |. underravel i.2 5
2 3 4 5 6
7 8 9 0 1
On Monday, July 26, 2021, 03:57:17 p.m. EDT, Elijah Stone <[email protected]>
wrote:
'Structural under' is an extension to under (&. &.:) that allows it to
operate on otherwise uninvertible structure-changing verbs. It is
implemented in dzaima/apl (https://github.com/dzaima/APL/).
For example:
-&.{. 1 2 3 4 NB. take the head, negate it, reaffix it to the rest of
the body
_1 2 3 4
}:&.}. 1 2 3 4 NB. remove the head, remove the tail, and then sew the
head back on
1 2 3
|:&.}. i.4 3 NB. remove the head, transpose the body, and then
reattach the head
1 2 3
3 6 9
4 7 10
5 8 11
|.&., i.2 3 NB. ravel, reverse, and then unravel
5 4 3
2 1 0
To make this functionality available to users, I suggest using .: for
'assign under', by analogy to :. and ::. Then:
u&.:(v .: vu) y ←→ vu y;u v y.
x u&.:(v .: vu) y ←→ vu x;y;(v x) u v y
The reason that vu is only applied monadically is to allow for the
expected identity:
u&.:(m&(v .: vu)) y ←→ m vu y;u v y
Thoughts?
-E
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm