We have seen the compose function on a previous slide.
Let us here work with a variant of compose called self-compose:
(define (self-compose-2 f) (lambda (x) (f (f x))))
You first job is to generalize self-compose-2 to self-compose*, which composes the f with itself n times:
(define (self-compose* f n) ...)
Test your function appropriately.
Also, program a function compose* which takes a list of functions as arguments. Each function in the list must be of a single parameter. Your function must return the composition of all the functions. Here is an example of the intended use of the function:
> ((compose* (list incr - fac)) 5) -119
fac is here supposed to be the factorial function, and incr is the usual increment function. The expression (compose* (list incr - fac)) should be equivalent to (lambda (x) (incr (- (fac x)))).
Are you able to program compose* with a reduction function and compose?