- take-right flist iprocedure
- drop-right flist iprocedure
take-right returns the last I elements of FLIST. drop-right returns all but the last I elements of FLIST.
(take-right '(a b c d e) 2) => (d e) (drop-right '(a b c d e) 2) => (a b c)
The returned list may share a common tail with the argument list.
FLIST may be any finite list, either proper or dotted:
(take-right '(1 2 3 . d) 2) => (2 3 . d) (drop-right '(1 2 3 . d) 2) => (1) (take-right '(1 2 3 . d) 0) => d (drop-right '(1 2 3 . d) 0) => (1 2 3)
For a legal I, take-right and drop-right partition the list in a manner which can be inverted with append:
(append (take FLIST I) (drop FLIST I)) = FLIST
take-right's return value is guaranteed to share a common tail with FLIST. If the argument is a list of non-zero length, drop-right is guaranteed to return a freshly-allocated list, even in the case where nothing is dropped, e.g. (drop-right lis 0).