Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
尝试运行代码时,我不断收到此错误:
(let ((exp lambda (x y) (if (= y 1) x (* (exp x (- y 1)) x)))))
错误:
let: bad syntax in: (let ((exp lambda (x y) (if (= y 1) x (* (exp x (- y 1)) x)))))
我的函数应该定义递归求幂,但我遇到了 let 的问题。
您在 之前缺少左括号lambda,并且let表单缺少正文。此外,您不能let用于定义递归函数;您需要使用letrec(for Scheme) 或labels(for Common Lisp)。也许你的意思是这个(方案):
lambda
let
letrec
labels
(letrec ((exp (lambda (x y) (if (= y 1) x (* (exp x (- y 1)) x))))) exp)