3 ms·
The reverse operators in APL are very visually suggestive if you imagine a matrix and mirror it about the centerlines- Reverse around last axis: ⌽ Reverse aro
by RodgerTheGreat 6y ago
The reverse operators in APL are very visually suggestive if you imagine a matrix and mirror it about the centerlines-
Reverse around last axis: ⌽
Reverse around first axis: ⊖
The grade operators (indices by which one could index to sort ascending or descending) are likewise easy to remember-
Grade up: ⍋
Grade down: ⍒
I suspect that the reason only a handful of APL's notational ideas made it into mainstream mathematics is because few mathematicians felt the need to describe algorithmic processes, and those who did were willing to settle for big sigma/pi, set builder notation, piecewise function notation, or a handwave at ALGOL, Pascal, or whatever else was in vogue at the time.
Their loss, I'm afraid.
- taeric 6y agoThis somewhat begs the question that those symbols are the best they can be, though. That is, yes, if you know one of those set of "grade" symbols, and you know that you can grade "up" or "down", then it somewhat follows. If you just show me those symbols flat out, though, I have no idea what they do. (Granted, I'm not entirely clear what it means to "grade" in this sense, either...) Of course, that also begs the question of "do we need characters for all operations?" But, I'm not entirely sure we do. What is the advantage? There are plenty of operations that are just fine with their symbol being a word. (As evidenced by programming, in general, right?)
- beagle3 6y ago"grade" (as opposed to "sort") means "find a permutation that puts this into order". So the sorted version of the list "name" is in APL, name[⍋name] (read "name indexed by the permutation that puts name into ascending order), but if you have two corresponding lists, "name" and "age", then you can get names sorted by age using name[⍋age]. It is, in that sense, a more fundamental operation than sorting. Before Iverson added the celing and floor symbols, those weren't known either, even though you had a better chance of guessing them. And w.r.t to "characters for all operators" - this is, of course, subjective. But I've never met a programmer who prefers COBOL's "ADD 1 TO X GIVING X" to C's "++x"; Anything that's common enough deserves a symbol, both because it's shorter and easier to recognize visually, and because it reduces the language barrier (in the same way that "3+4" is easy for a 6-year old Thai in the way that "3 plus 4" in English letters isn't) In my opinion Arthur Whitney's refinements of Iverson's ideas (called "K", an APL-related-language) is the right way to go. He mostly converged on ~50 operations that deserve symbols. Many algorithms end up as orthogonal combinations of those, e.g. |/0(0|+)\ which is a complete, efficient O(n) solution of the maximum-subarray-sum problem; or ",//:" which is a complete, though not very efficient, implementation of "flatten".
- taeric 6y agoCertainly I think things that you do regularly and that we can pull back to the standard tools of associative and distributed computations makes sense to do so. I confess that I am less clear on why to do this on things that cannot be pulled back to those conventions. I further have to acknowledge that there is a non-fine line on where to stop, though. Otherwise, near every job function at work would have a unique symbol for it. :D That is to say, I was not intending to contradict you. Just trying to shine light on the ambiguous part.
- nyanpasu64 6y agoIIRC Numpy calls it "argsort", though I don't know if that's any more intuitive of a name than "grade".
- beagle3 6y agoIt is intuitive if you are familiar with "argmax" and friends.
- yiyus 6y agoMy personal favorites are x*y and x⍟y for pow and log, and the *x and ⍟x monadic versions for exp and ln. I always found weird that exponentiation and logarithms were not defined by operators in conventional math notation.
- dirkt 6y agoIntersestingly enough, set builder notation has made its way as "list comprehension" or even "set comprehension" into many programming languages now.