If f is a numerical function and n is a positive integer, then we can form the
Question:
If f is a numerical function and n is a positive integer, then we can form the nth repeated application of f, which is defined to be the function whose value at x is f(f(…(f(x))…)). For example, if f is the function f(x) = x + 1, then the nth repeated application of f is the function f(x) = x + n.
Define a function repeated that takes as input a procedure that computes f and a positive integer n and returns a function that computes the nth repeated application of f. Your function repeated should permit the following usage:
In this example, quad is a function which, given a number x, returns (+ (* 2 x) 1). repeated is a function that takes a function (quad in this case) and another number (2 in this case) and returns a function that applies the quad function twice on 2:
Step by Step Answer:
An Experiential Introduction To Principles Of Programming Languages
ISBN: 9780262045452
1st Edition
Authors: Hridesh Rajan