相关疑难解决方法(0)

函数声明中的最大参数数

我知道函数定义中的最小参数数量为零,但函数定义中的最大参数数量是多少?我只是为了知识和好奇而问这个问题,而不是我要写一个真正的功能.

c c++ limits function-parameter function-declaration

27
推荐指数
3
解决办法
3万
查看次数

常见的lisp:函数可以使用多少个参数?

可能重复:
在Lisp中,+函数实际上有多少输入?

以下代码给出了"太多参数"错误:

(setf u (loop for i upto 50000 collect 1))
(apply #'+ u)
Run Code Online (Sandbox Code Playgroud)

同样的

(apply #'= u)
Run Code Online (Sandbox Code Playgroud)

所以我想当用&rest写defun时,参数数量有一个上限.它是什么?我在这里搜索并尝试该网站上的各种页面,但我无法弄清楚这一点.

common-lisp

3
推荐指数
1
解决办法
449
查看次数

在循环中从用“with”定义的变量调用 lambda 函数

我有以下 lisp 代码

(defun sum (vec)
  "Summiert alle Elemente eines Vektors."
  (apply '+ vec))

(defun square (item)
  "Hilfsfunktion zum Quadrieren eines Elements."
  (* item item))

(defun calcVarianz (vec)
  "Berechnet die Varianz eines Vektors."
  (loop with len = (length vec)
        with mean = (/ (sum vec) len)
        with some_func = (lambda (x) (* x x))
        ; causes the error
        for item in vec
        collecting (square (- item mean)) into squared
        collecting (some_func item) into some_vector
        ; some_func cannot be found
        finally …
Run Code Online (Sandbox Code Playgroud)

lisp common-lisp

1
推荐指数
1
解决办法
139
查看次数