Search code examples
pythonlistlispcommon-lispiterable-unpacking

Common Lisp -- List unpacking? (similar to Python)


In Python, assuming the following function is defined:

def function(a, b, c):
    ... do stuff with a, b, c ...

I am able to use the function using Python's sequence unpacking:

arguments = (1, 2, 3)
function(*arguments)

Does similar functionality exist in Common Lisp? So that if I have a function:

(defun function (a b c)
    ... do stuff with a, b, c ...

And if I have a list of 3 elements, I could easily use those 3 elements as parameters to the function?

The way I currently implement it is the following:

(destructuring-bind (a b c) (1 2 3)
    (function a b c))

Is there a better way?


Solution

  • apply