3 ms·
That's what people do on codegolf.stackexchange.com with the dedicated golfing languages. What's interesting about APL is that it started out as linear algebra
by jodrellblank 3y ago
That's what people do on codegolf.stackexchange.com with the dedicated golfing languages. What's interesting about APL is that it started out as linear algebra and became array programming, and the primitives are more "things which are useful transforms to do on arrays" rather than "thing people wanted to do in one problem turned into a symbol", and that's enough to be useful in many tasks.
> "That would be insanely nice if you’re doing something which just requires thinking about sorting and reversing arrays but all together, very poor thing to build a standard language on."
Prolog has linked lists as its main data structure, which means prepend is more performant than append. In the SWI Prolog documentation for foldl[1] it says "No implementation for a corresponding foldr is given. A foldr implementation would consist in first calling reverse/2 on each of the m input lists, then applying the appropriate foldl. This is actually more efficient than using a properly programmed-out recursive algorithm that cannot be tail-call optimized". i.e. you don't have to have a problem which involves reversing arrays, for reverse to be a useful part of a solution.
In APL reverse is one character ⌽. In C# to find the first comma in a string you use IndexOf(',') and to get the last one you use LastIndexOf(','). In APL you would use the equivalent of indexOf(Reverse(string)) and then you wouldn't need the specialised LastIndexOf - and wouldn't every other function which works from the left of a string or array to have an equivalent which works from the right. https://aplcart.info/ https://aplcart.info/ is a database of idioms and samples of useful APL and it has 168 pieces of code using ⌽.
[1] https://www.swi-prolog.org/pldoc/man?predicate=foldl/4 https://www.swi-prolog.org/pldoc/man?predicate=foldl/4