This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Is there a function?

4 posts · 1139 views

hello all!
Is there a function that takes a list and returns multiple arguments, one for each element in the list?
this would be the opposite of LIST (which takes multiple args and makes them into a list)
for example:
(mysteryfunction '(1 2 3))
1 2 3

((extra information: i need this because i have a function that takes 6 args, the last three of which are in a list of three arguments. i realize that i could use car, cadr, then caddr but that would be much messier))

thanks! :D

Re: Is there a function?

There is APPLY. It uses spreadable argument lists, which means that in addition to the function to call it takes a variable number of arguments the final of which must be a list. Also see functions chapter of Practical Common Lisp.
CL-USER> (defun example-6 (a b c d e f) (+ a b c d e f))
EXAMPLE-6
CL-USER> (apply #'example-6 1 2 3 (list 4 5 6))
21

Re: Is there a function?

thanks!!