【发布时间】:2021-05-28 14:24:40
【问题描述】:
我要解决方案问题
我定义代码二、三、平方、加
二是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))
我不知道为什么错了,请告诉我
【问题讨论】:
标签: scheme
我要解决方案问题
我定义代码二、三、平方、加
二是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))
我不知道为什么错了,请告诉我
【问题讨论】:
标签: scheme
你混淆了函数的数量。 three 和 two 不是两个参数的函数。它们是接受参数并返回函数的函数。返回的函数再次接受一个参数。
尝试评估以下内容:
(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)))
【讨论】: