6 ms·
I'm a fan first/rest because of Mathematica. It has four functions that all end in "st", which means I can always recall the one I need: First, Rest, Most, Las
by lgarron 13y ago
I'm a fan first/rest because of Mathematica. It has four functions that all end in "st", which means I can always recall the one I need:
First, Rest, Most, Last
(Results on Range[4], respectively: 1, {2, 3, 4}, {1, 2, 3}, 4.)
- draegtun 13y agoRebol comes with first & last but not the others. >> a: [1 2 3 4] == [1 2 3 4] >> first a == 1 >> last a == 4 This is how you could add rest & most: >> rest: func [s] [next s] >> most: func [s] [copy/part s back tail s] >> rest a == [2 3 4] >> most a == [1 2 3] Rebol unifies all this under what it calls a series - http://www.rebol.com/docs/core23/rebolcore-6.html http://www.rebol.com/docs/core23/rebolcore-6.html
- lcedp 13y agoIn Clojure it's almost the same: first, rest, butlast, last