有效地将参数列表拼接到函数调用中

Effectively Splicing a List of Arguments into a Function Call

一些 Common Lisp 列表和序列函数可以将多个列表或序列作为它们的最终参数。例如:

(mapcar #'list '(a b) '(c d) '(e f)) => ((a c e) (b d f))

但是如果最后的参数已经像((a b) (c d) (e f) ...)一样被合并成一个list/sequence,你怎么能达到同样的结果呢(就好像把list/sequence拼接到了原函数中一样) ?有没有比写宏更直接的方法?

编辑:我想我找到了一种方法:(apply #'funcall #'mapcar #'list '((a b) (c d) (e f))) 但可能还有其他方法。

您使用 apply,它将 可扩展参数列表指示符作为最后一个参数

以你的例子为例:

(apply #'mapcar #'list '((a b) (c d) (e f)))