Re:The Array Cast – A podcast about the array programming la...
by dzaima on Thursday May 20, 2021 @02:18PM
(#27224991)
I don't think $ is of worthy note here. It's literally a builtin for cycling data, that's what it does.
All simple arithmetic follows leading axis agreement[1] (so erroring on mismatched length, and mapping over cells for high rank). Don't know much about other builtins, but, unless J does some weird stuff I don't know about (I don't know much of J), it shouldn't be too illogical.
Re:The Array Cast – A podcast about the array programming la...
by klibertp on Thursday May 20, 2021 @03:37PM
(#27226037)
> I don't think $
You're right, although cycling instead of erroring out was surprising to me. Another verb I had trouble with is roll/deal: https://code.jsoftware.com/wiki/Vocabulary/query
> it shouldn't be too illogical.
I'm not saying it's illogical. I'm pretty sure there are good reasons behind the design of each word, especially since there are so few. As I mentioned, I suspect it's just a matter of me not getting enough exposure to the various use-cases of many standard words.
Re:The Array Cast – A podcast about the array programming la...
by slver on Thursday May 20, 2021 @02:01PM
(#27224730)
Gotta say, "depends on the operation" was the most unfortunate possible answer to my question, alas :-) Maybe one day we'll figure out how to make a consistent array language ;-)
Re:The Array Cast – A podcast about the array programming la...
by thrwaeasddsaf on Friday May 21, 2021 @04:34AM
(#27231736)
Why is it unfortunate? It's entirely plausible that they've managed to pick the behavior that makes most sense for each operator. Different operators being different, it doesn't make sense to expect all to behave the same. And it would be unfortunate if the common use cases were complicated by having to code out the sensible behavior if the defaults were wrong.
Re:The Array Cast – A podcast about the array programming la...
by klibertp on Thursday May 20, 2021 @03:27PM
(#27225878)
Well, for what it's worth - and as mentioned by a sibling poster - most verbs, and certainly all arithmetic operators, obey a few simple rules for determining which behavior you'll get. I should have noted this, before I started whining about all the other verbs, which don't :D
Re:The Array Cast – A podcast about the array programming la...
by ithkuil on Thursday May 20, 2021 @02:21PM
(#27225026)
Give this a try: https://t3x.org/klong/klong-ref.txt.html
EDIT: forgot to mention, you can also control the effective rank of the verb, like this:
the `<` verb means "box", without the `"n` part you'd get the last value, which is a 1-dimensional array of boxes of length 1 (with 2x2 array inside the box). By selecting rank of the verb, you can decide on which level the verb should be applied: with `"0` it's applied to the smallest possible chunks of the array (cells - you get 2x2 array of boxes), with `"1` you apply the verb to bigger chunks (rows), and so on, for input arrays of any dimensions (so if you have a 3x2x2 array, `"2` will apply the verb to the 3 2x2 arrays).