Lisp function call error

后端 未结 4 550
傲寒
傲寒 2021-01-19 12:56

I\'ve written a Lisp function like this:

(defun power (base exponent)
  (if (= exponent 0)
      1
    (* base (power (- exponent 1)))))

Wh

4条回答
  •  走了就别回头了
    2021-01-19 13:45

    Lisp comes with the function expt, so no need to define your own.

    (Unless this is an exercise or homework, in which case you might want to look at more efficient methods, such as exponentiation by squaring.)

提交回复
热议问题