Question: Here are some definitions: > double x = 2*x > square x = x*x > twice f x = f (f x) > quad =

Here are some definitions:

> double x = 2*x

> square x = x*x

> twice f x = f (f x)

> quad = twice double

> fourth = twice square

- What is the type quad? Do not use ghci for this. Give your reasons for your type.

- What is the type of fourth? Do not use ghci for this. Give your reasons for your type.

- Check your types in ghci. If they are different, justify the haskell type and where your assumptions differ.

- Generalize the twice function above to repeat with the following specification:

repeat f 0 x yields x

repeat f 1 x yields f x

repeat f 2 x yields f (f x)

repeat f 3 x yields f (f (f x)) and so on.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!