@Richard Maximum commutes with concatenation: (⌈/A,B)=(⌈/A)⌈⌈/B, and it's really convenient when your algebraic identities always hold, e.g (⌈/A)=(⌈/A,⍬)=(⌈/A)⌈⌈/⍬.
I'm just an APL newbie here, but in the small bits of code I've poked at, empty arrays form an essential part of the base case data structure that everything else operates over.
So, in my limited applications at least, I try hard to avoid conditional code, and empty-array sympathetic primitives is something I absolutely love about (modern?) APL.
@essielovett Link really is nice, especially the bidirectional sync. That said, if you're using an external editor, you'll almost certainly hit some race conditions that cause changes to get randomly missed and/or the link to stop working.
I've looked into this a bit, but if you find anything, would you mind pinging me on the thread?
@essielovett I like the variant allowing non-overlapping matches. Whilst you can do that with lookaheads, it's very nice to have it easily accessible. I've not seen that anywhere else.
@dzaima and it largely can't - consider {f} - is that a valid dfn? it might be if f is an array, but not if it's a function or operator. And the class of a variable can change over time
Well, my original question really is why are bare dyadic operators syntax errors when monadic ones aren't? E.g. op←⍨ does what you expect, but op←∘ is a syntax error.
@dzaima Hrm. Okay. So {} pretty much just act like string delimiters at the parsing stage? Would it be terribly off to say that they're weird strings, where free variables at execution time have lexical scope?
I'm somewhat familiar. I sometimes want such, but then again, it massively increases the amount of patterns to remember. Look how much hate the forky trains are seeing due to their added complexity. Now multiply that complexity by 40 or so…
@essielovett Not sure if it's better, but {cond: {0:: dangerous ⋄ doThis}⍬ ⋄ cond2: blah ⋄ otherwise} ?
Really, though, if I was reaching for this kind of code, I'd probably want to start zooming out to find some architecture that permits a more direct/simple/APLy solution.
@Adám @dzaima Hrm. I kind of feel silly for just discovering this. Is this a design decisions or something? Seems straightforward enough to detect monadic dfns and throw an error.
Though there might be some exciting abuse that I'm not seeing :)
@Adám Same could be said for tradfns. To be clear, though, I'm not disagreeing with the design, just mildly surprised, and now wondering about potential uses.
@Adám It's not that important, really. I'd be more interested in example cases where one might want to eat left arguments, instead of simply not writing the left argument.
Off the top of my head, I can only think of contrived examples using Execute.
In the docs Programming Reference Guide / Introduction / Operators, should the list at the beginning really have "an array or function to the right of a monadic operator." as item 5?