Re:Why Learn Haskell? (2018)
by pierrebai on Monday March 01, 2021 @02:45PM
(#26307378)
Curious: why last takes the quantity second, unlike nth? That inconsistency would drive me mad.
[ Parent
| on HN ]
The default behavior of last is literally returning the last cons. So:
(last '(1 2 3)) ;; => (3)
The signature for last is: last list &optional n => tail
If n is not provided, it defaults to 1 so the behavior and order of parameters is sensible in this context.http://www.lispworks.com/documentation/HyperSpec/Body/f_last...
It's also worth noting that along with nth which takes the index first, there's elt which takes a sequence as the first parameter and index as the second. aref is similar but restricted to arrays and permits multiple numbers for the subscripts since arrays can be multidimensional. char, which accesses characters in a string, takes the string first and index second as well. bit takes the bit array as the first parameter and the subscripts follow it.