3.9 Functions of Functions in Calculus

Answers to Exercises

Problem 1

• Create a function that cubes every element of a list, using map as your only named function.

rex> cube(L)=map((X)=>X*X*X,L);

Problem 2

•• Describe the functions represented by the following functional expressions:

(X) => X + 1
The function which, with argument X, returns the value of X + 1

(Y) => Y + 1
The function which, with argument Y, returns the value of Y + 1

(X) => 5
The function which returns the value 5

(F) => F(2)
The function which, applied to the argument 2, returns the value 2

(G, X) => G(X,X)

(X, Y) => Y(X)
The function which, with arguments X and Y, returns the value of the X argument to the function Y

Problem 3

•• Argue that compose(F, compose(G, H)) == compose(compose(F, G), H), i.e. that composition is associative. Written another way, F o (G o H) < (F o G) o H. This being the case, we can eliminate parentheses and just write F o G o H.

Problem 4

••• Express the calculus chain rule for the composition of three functions:

(f o g o h)' = ??

Problem 5

•• In some special cases, function composition is commutative, that is (F o G) == (G o F). Give some examples of such cases. (Hint: Look at functions which raise their argument to a fixed power.)

Problem 6

•• Give an example which shows that function composition is not generally commutative.

Problem 7

•• Which functional identities are correct?

map(compose(F, G), L) == map(F, map(G, L))
Incorrect

map(F, reverse(L)) == reverse(map(F, L))
Correct

map(F, append(L, M)) == append(map(F, L), map(F, M))
Correct


Return