Im looking for a way to extract all the elements of a list in common lisp. Like this
[194]> (break-out-of-list '(a b c d))
A
B
C
D
Edit: The usage example I gave was not thought out very well, however I'm still curious if it is possible to break out of a list like in the example above.
While
(apply #'values '(1 2 3))
works there is also a function to this calledvalues-list
which is used like this:And it has the same result.
I think you might be looking for this:
http://cl-cookbook.sourceforge.net/macros.html#LtohTOCentry-2
Reading your comments:
With this, you could do:
and you'd get:
Sure, just use
apply
:This technically doesn't "break out of list"; it simply uses a list's elements as arguments to a function call.
(Disclaimer: I'm a Schemer, not a Common Lisper, and there may be a more-idiomatic way to achieve the same result in CL.)
What you demonstrate seems to be the question how to get the elements of a list as multiple values:
See also
multiple-value-bind
andnth-value
in the hyperspec.