Re: [Jprogramming] Feature proposal: structural under

2021-12-16 Thread Elijah Stone
On Mon, 26 Jul 2021, Marshall Lochbaum wrote: Structural Under isn't always compatible with the existing Under. The other examples you give are arguably mistakes, but here is one which is not: >. -&.>1 gives <_1; but the same sentence with structural under in place of &. should give _1, ret

Re: [Jprogramming] Feature proposal: structural under

2021-07-26 Thread 'Pascal Jasmin' via Programming
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 co

Re: [Jprogramming] Feature proposal: structural under

2021-07-26 Thread Marshall Lochbaum
Yes, not all structural functions can be recognized (I use "well defined" in the mathematical sense meaning that the definition never allows two conflicting results for the same arguments; it's actually sort of a complement to "defined"). In practice recognizing structural functions isn't difficul

Re: [Jprogramming] Feature proposal: structural under

2021-07-26 Thread Raul Miller
Your concept of a structural function might be well defined mathematically, but it's not clear to me that recognizing structural functions could be efficiently implemented for the general case of user defined structural functions. I think this means that you wind up requiring the user to declare w

Re: [Jprogramming] Feature proposal: structural under

2021-07-26 Thread Raul Miller
This breaks existing uses of under, which means that you would need a different token (or word) to represent structural under. And, if you're doing that, it would make sense to define a new word to represent "structural under". But, also, this gets into issues of rank and depth and what is intend

Re: [Jprogramming] Feature proposal: structural under

2021-07-26 Thread Marshall Lochbaum
I'm the inventor(?) of structural Under. I won't comment on whether it makes sense for J but can offer a little more context. The operation is well defined: here's a specification with proof. It's pretty difficult because it needs to support arbitrary paths into a nested array, but would be much s

Re: [Jprogramming] Feature proposal: structural under

2021-07-26 Thread Elijah Stone
On Mon, 26 Jul 2021, Raul Miller wrote: I think that the problem here would be in defining vu to work in your examples. I definitely don't think that's the problem! Here are some definitions; untested, but hopefully illustrative: ',': $@>@{. $ >@{: '{.': >@{: , }.@>@{. '}.': {.@>@{. , >

Re: [Jprogramming] Feature proposal: structural under

2021-07-26 Thread Raul Miller
I think that the problem here would be in defining vu to work in your examples. If you could do that, I think you would have something. Without that, though, we would need a different approach. Thanks, -- Raul On Mon, Jul 26, 2021 at 3:57 PM Elijah Stone wrote: > > 'Structural under' is an e

[Jprogramming] Feature proposal: structural under

2021-07-26 Thread Elijah Stone
'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