常见错误:一个函数可以接受多少个参数? [英] Common lisp: How many argument can a function take?
本文介绍了常见错误:一个函数可以接受多少个参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码给出参数过多错误:
The following code gives a "too many argument" error:
(setf u (loop for i upto 50000 collect 1))
(apply #'+ u)
对于
(apply #'= u)
因此,我猜想用& rest编写defun时,参数数量是有上限的。它是什么?我在此处搜索并尝试过
So I guess when writing defun with &rest there is an upper bound for the number of arguments. What is it? I searched and tried here and various pages on that site but I couldn't figure this out.
推荐答案
有一个名为CALL-ARGUMENTS-LIMIT的常量,该常量给出了可以传递给函数的参数个数的上限。
There is a constant called CALL-ARGUMENTS-LIMIT that gives you the upper bound of how many arguments you can pass to a function.
但是,在最初的示例中,您绝对可以使用REDUCE:
However, in your initial example, you can definitely use REDUCE:
(reduce #'+ u)
这篇关于常见错误:一个函数可以接受多少个参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文