Format: (butlast <list> ) (butlast <list> <int> )
Required arguments: 1
First argument must evaluate to a list
Optional arguments: 1
<int> must evaluate to an integer
If butlast is used with a single argument then it is equivalent to (reverse (rest (reverse <list> ))). I.e. it will return the list argument with the last element removed.
If butlast is given an integer second argument, it is equivalent to (reverse (nthcdr <num> (reverse <list> ))). I.e. it will remove the number of elements specified from the end of the list.
Examples:
> (butlast '(a s d f)) (A S D) > (butlast '(a s d f) 2) (A S) > (butlast '(a s d f) 0) (A S D F) > (reverse (nthcdr 2 (reverse '(a s d f)))) (A S)
© Colin Allen & Maneesh Dhagat