MULTIPLE-VALUE. There are built-in variants for some standard operators; it's easy to create your own variants for other operators. The multiple-value mapping operators are especially useful.The currently supported built-in multiple-value variants are:
(progn prog1 and or cond when unless case ccase ecase typecase ctypecase etypecase mapcar mapcan maplist mapcon)
Here are some examples of multiple-value mapping:
(multiple-value (2)
(mapcar #'truncate '(3 5/4 5.5)))
=> (3 1 5), (0 1/4 0.5)
(multiple-value 2
(mapcan (lambda (object)
(if (numberp object)
(values (list object) nil)
(values nil (list object))))
'(0 a 2 3/4 c)))
=> (0 2 3/4), (A C)
(multiple-value 3
(maplist (lambda (tail)
(values tail
(reverse tail)
(list (first tail) (second tail))))
'(a b c d e)))
=>
((A B C D E) (B C D E) (C D E) (D E) (E))
((E D C B A) (E D C B) (E D C) (E D) (E))
((A B) (B C) (C D) (D E) (E NIL))
multiple-value-variants is in Quicklisp:
(ql:quickload "multiple-value-variants")
See the project's home for further information. Actual documentation is in the README.
This library is in the Public Domain. See the UNLICENSE file for details.
convenience library