2015/10/09

SICP 問題1.43

関数fをn回作用を計算する手続きrepeated

(define (repeated f n)
  (define (iter fn count)
    (if (= count n)
        fn
        (iter (compose f fn) (+ count 1))))
  (iter f 1))
gosh> ((repeated inc 5) 0)
5

© 2022 wat-aro