Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List 使用Common Lisp编程-多次调用同一列表作为参数调用函数_List_Common Lisp - Fatal编程技术网

List 使用Common Lisp编程-多次调用同一列表作为参数调用函数

List 使用Common Lisp编程-多次调用同一列表作为参数调用函数,list,common-lisp,List,Common Lisp,我几天前刚开始用Lisp编程,一直在玩列表 我有一个可以获取一个或多个列表的函数。如果我希望它包含50个列表,我必须键入列表引用或列表50x 我创建了另一个函数,其功能如下: (if (= n 1) (setq combine (comboN '(0 0 1 2 4 6)))) (if (= n 2) (setq combine (comboN '(0 0 1 2 4 6) '(0 0 1 2 4 6)))) 我要为所有的N做这个吗?我尝试使用从1到任意数字x的循环,但只能以这种方式

我几天前刚开始用Lisp编程,一直在玩列表

我有一个可以获取一个或多个列表的函数。如果我希望它包含50个列表,我必须键入列表引用或列表50x

我创建了另一个函数,其功能如下:

(if (= n 1) 
  (setq combine (comboN '(0 0 1 2 4 6))))
(if (= n 2)
  (setq combine (comboN '(0 0 1 2 4 6) '(0 0 1 2 4 6))))
我要为所有的N做这个吗?我尝试使用从1到任意数字x的循环,但只能以这种方式打印列表的x个副本


如有任何建议,将不胜感激。不确定是否可以使用common lisp执行类似操作。

如果您想要一个包含大量同构参数的函数,则应使用:

如果要使用大量参数调用此函数,但不想全部键入,可以使用:


请注意,这只是ANSI Common Lisp语言的一个实现。

comboN的具体功能是什么?您是否正在寻找接受长度和元素并返回包含该元素的长度列表的函数?您可以这样做(setq combine(应用'comboN(生成列表n:初始元素'(0 0 1 2 4 6)))。
(defun foo (&rest args)
   (print args))
(foo 1 2 3)
==> (1 2 3)
(apply #'foo (loop repeat 20 collect 1))
==> (1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)