【发布时间】:2010-12-15 15:46:09
【问题描述】:
在Python中,假设定义了如下函数:
def function(a, b, c):
... do stuff with a, b, c ...
我可以通过 Python 的序列解包来使用该函数:
arguments = (1, 2, 3)
function(*arguments)
Common Lisp 中是否存在类似的功能?所以如果我有一个功能:
(defun function (a b c)
... do stuff with a, b, c ...
如果我有一个包含 3 个元素的列表,我可以轻松地将这 3 个元素用作函数的参数吗?
我目前的实现方式如下:
(destructuring-bind (a b c) (1 2 3)
(function a b c))
有没有更好的办法?
【问题讨论】:
-
请注意,
,@是相似的。例如,(let ((x '(2 3))) `(1 ,@x 4 5))变为(1 2 3 4 5)。
标签: python list lisp common-lisp iterable-unpacking