应用组合物公式(define (compose g f) (lambda (x) (g (f x))))
以构建2 ^ n! n的函数的非尾部和尾部递归实现!和2 ^ n。
对于n!和n 2我想
(define (factorial n)
(fold * 1 (iota n 1)))
(define (two-to-the n)
(fold * 1 (make-list n 2)))
我将如何为2 ^ n构建它!? 也许
(define (two-to-the factorial n )
(fold * 1 (iota n 1)))(fold * 1 (make-list n 2)))
答案 0 :(得分:2)
(define two-to-the-factorial (compose two-to-the factorial))