如何在方案2中构成n阶乘

时间:2014-07-09 18:13:42

标签: scheme

应用组合物公式(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)))

1 个答案:

答案 0 :(得分:2)

(define two-to-the-factorial (compose two-to-the factorial))