Question 3-2

Write a Haskell function named doubleFunc which takes as its parameter a function f from integers to integers and returns a function from integers to integers which is always twice f. For example, using this function I should be able to do the following.

f x = x + 5
g x = 3 * x
fd = doubleFunc f
gd = doubleFunc
With these definitions, fd 3 should return 2 f(3) = 2 (3 + 5) = 16$ and gd 10 should return 2 (3 * 10) = 60.

Solution

doubleFunc f = \x -> 2 * f(x)

Back to Quiz 3