刚开始学习Lisp。我不知道为什么我会收到这些错误,甚至是什么意思。我只是尝试使用Gregory-Leibniz系列编码pi的近似值,这是代码。
(defun gl (n)
(defparameter x 0) ;init variable to hold our runnning sum
(loop for y from 0 to n ;number of iterations, starting from 0 to desired n
(if (= y 0) ;if n is 0 then we just want 4
(defparameter w 4))
(if (> y 0) ;else, 4*(-1^y)/((2 * y)+1)
(defparameter w (* 4 (/ (exp -1 y) (+ (* 2 y) 1)))))
(+ x w)) ;add to our running sum
(write x)) ;once loop is …Run Code Online (Sandbox Code Playgroud)