3 ms·
"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
by 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.