(define (repeated f n)
if (= n 0)
f
((compose repeated f) (lambda (x) (- n 1))))
I wrote this function, but how could I express it more clearly using simple recursion with repetition?
Sorry, I forgot to define my layout function.
(define (compose f g) (lambda (x) (f (g x))))
And the function takes as inputs a procedure that calculates f and a positive integer n, and returns a procedure that calculates the nth reapplication of f.
dave jones
source
share