@rak1507 Nic wrote: "I don't block this proposal, but I don't support it either. To me it's just a convenient hack. We'd rather have a global discussion about how to "fill" arrays, and try to come up with a unified approach to all cases (⎕MAP, ⍴, ↑, ⌺, etc.)"
For context, I was pointing out that ⎕MAP has ¯1 with this meaning already, but no ¯2 or ¯3, which I was then proposing to add.
I see where he's coming from but I'd be scared that saying 'we're not doing this until we do lots of other stuff too' results in nothing getting done for ages
I've seen that before (the company name, not the 4 step thing)
It seems right, I've done that before, I was doing something in haskell for example and I thought 'hmm I'm basically composing a bunch of things' and got lost trying to work out how monoids work rather than just doing the task at hand
I have a quite large number of "minor"/"medium" feature suggestions in the works, but a lot of them have already been blocked. My first one was extending :Repeat to allow :Repeat N but that was blocked for "lack of usefulness; insufficient justification for doing it."
My second launched suggestion just got approved, though. So hooray, I guess. But it is very minor and technical.
I doubt I'm gonna be able to speed it up by ~8 times which is what would be required for it to be a valid submission... oh well looks like c++ wins this one!
@Adám ↑ and ⎕MAP cannot be unified. ⌺ has different enough needs for there to not be any connection (and any would probably be confusing at best). Extending ⍴ to allow a stop-short ¯1 and then adding an erroring ¯2 as a better version seems reasonable. (and, if need be, this can be extended later on)
@dzaima Fit only specifies what to fill with, so when using more elements than available, it allows filling with something else than the recycled data. So if J had guess-reshape (it doesn't) then it could be defined as recycling, since filling was available through Fit.
And yes, a special element in the left argument is the obvious choice. K uses that too.
I'd be happy with null if null wasn't so clunky.
Heh, how about any "ref", then with array notation, one could write ()2⍴ and 2()⍴ and the namespace could even have the options, so (mismatch:'truncate')2⍴ and (mismatch:'error')2⍴ and (mismatch:'recycle')2⍴ and (mismatch:'pad')⍴ and (mismatch:'pad' 42)2⍴
Of course, these are probably all longer than the APL code to implement them, and the namespace will probably slot things down unacceptably, but hey…
@dzaima Sure more understandable, but a special element in the left argument actually occupies the relevant spot. Not sure about that identity bracket though.
@dzaima Sure, the bracket would mean there's one missing axis, and since the first slot is taken, and you can't skip axes, the "guess" axis must be number 2.
Very awkward in practice. The inverse (yours) is absolutely easier to use.
Moot point, though. Dyalog will never add more such anomalies. A special left argument element is at least theoretically possible to get.
@dzaima Supposedly, bracket axis is to indicate the axis or axes being worked on. At least my long form does that. Yours indicates which axis is not being reshaped to the given lengths. Compare to 2 7 1 8⌷[1 3 4 5]
@dzaima But you can't have more than one element in ax, can you?
@dzaima I think fills are a lot messier than Undo/Under. In fact even identity elements are probably hackier as well: how do I justify that the identity element of ≠ is 0?
@Adám ⥊ isn't exactly J's $, which only operates on the leading axis of its right argument. Not sure what you're getting at. Do you mean the monad/dyad pairing?
@dzaima I guess I could probably allow using an identity element for the largest closed domain for the function (which for ≠ is just the range). That would still be unique because the union of any two closed domains is still closed, so the largest closed domain is well-defined, and there can only be one identity (whether left or right) in a given domain.
Yeah, I think that in most cases of reshape, the argument is a vector, so having a non-ravelling reshape wouldn't matter. In the few that do need a ravel, an explicit ravel is fairly cheap, but in those cases that need J's $ it is quite awkward to get that, so I'd define ⥊ as $.
@Marshall Yeah, I thought about that, but then it becomes hard to use in a train. It'd be nice with a way to specify that g should only be applied to the right or only to the left argument.
@Adám The inverse of a constant function (such as an array) is defined to be the function that errors if its argument doesn't match the constant, and otherwise returns the constant.
Ah, and a list is an array, hence it is under that constant function. I see.
I now understand that this won't work, because of that rule (which I myself support). Still, hanging on to the thought for a moment, there'd be no need for a special value ∘ since ⊢‿g and g‿⊢ would have worked. Oh well.
@Adám Oops, didn't notice that. Split it into (g1⊸(g1⁼f))⟜g2 or g1⊸((g2⁼f)⟜g2). Although of course you can pass an array operand, but that's not too different from just assigning the three names.
@rak1507 That's like my signature function. I've been complaining that it's not in J for the better part of a decade, added it to Dyalog, and of course it's in the BQN spec.
@Adám either that, or it takes another arg of wanted length or something.
i defined T ← ≠⊸↑⟜(/⁼) in some code using it - right arg is the regular arg, and left is an array in which the indices would be (only used for the length, but I found it to be much better this way)
@dzaima But if you are to supply the length, you might as well just use ↑, and all-knowing seems impossible unless you say that it should be God, which would be the strangest religion ever.
I remember a day in 1975 or so, i wa17? years old in an APLSV class taught at IBM Essex Junction Vermont. It was part of the Boy Scouts called the Explorers. One did not have to be a Boy Scout though. All that was needed was $4.00 twice a year. The teacher of the class wanted a solution to a problem. Write the smallest code which, using incremental numbers, say 1 - 25 and arrange them as follows...
@dzaima (fwiw if monadic and dyadic / weren't so nicely related and were on different characters, one could even have only the inverse builtin (with an optional left arg of the length), the inverse of which would be the regular ⍸)
yes. filling the array diagonally. There was a young kid in the class who had an answer usin 7 keystrokes that would do a 5 by 5 array. I think his answer used encode or decode.
All of these things look very complicated. They have my head spinnning. I don't know much complicated APL. I just remembered the quiz my teacher gave us and that someone had a very good answer.
If i sit and ponder each of them i would understand after a while, but i have to go know. Please feel free to continue the subject. I'll check back sometime later.
Consider the following function, which should return a function that adds two to any given argument:
∇r←addtwo
r←{⍵+2}
∇
This code loads without any errors, but I just cannot use the return value without causing errors.
addtwo ⍝ doesn't cause errors
addtwo 1
VALUE ERROR
addtw...
@Adám just branches for temporary experiments, this is not uncommon with git. btw, your fork is from 9 years ago. i think you'd better delete it and fork again (or if you're more comfortable with git's cmd line: merge from upstream)
Yeah, for some of them, I had to solve them all too, and for all, I had to check that the availability of modern primitives didn't mess up things. So while the puzzles might have had unambiguous answers at the time of their publication, there are now many places where you can use ⌿ instead of / or ≢ instead of ⍴ etc.
And where multiple solutions are possible, the automated checker needs to recognise all possibilities.
@ngn ngn/apl has ⌸ on its language bar, but is it actually implemented?
I barely ever upload. I just go to imgur.com/upload and paste, then wait a second, click-click, "Copy image location", and paste that. to avoid one-boxing, simply copy the initial imgur URL, without the "right-click etc."