scheme问题代码不知道为什么错了

scheme question code don't know why wrong

我要解决scheme问题

我定义代码二、三、sq、plus

二是 f(f(x)) // 三是 f(f(f(x)))

sq 是平方函数 ex ((two sq)3) 是 81

加上是

(define (plus m n)
             (lambda (f) (lambda (x) (m f (n f x))

我不知道为什么错了请告诉我

你混淆了函数的数量。 threetwo 不是两个参数的函数。它们是带有参数和 return 函数的函数。 returned 函数再次接受一个参数。 尝试评估以下内容:

(let ((inc (lambda (x) (+ x 1))))
  (list ((three inc) 0)
        ((two inc) 0)))

您的加号应该是:

(define (plus m n)
  (lambda (f) (lambda (x) ((m f) ((n f) x)))))

现在这应该给你 (3 2 5)

(let ((inc (lambda (x) (+ x 1))))
  (list ((three inc) 0)
    ((two inc) 0)
    (((plus two three) inc) 0)))