Op 30-10-2015 om 08:00 schreef Sean Leather:
On Fri, Oct 30, 2015 at 8:52 AM, Roelof Wobben wrote:
Let's say f is a recursive function which calculates the fac. 

So f 0  = 0
f1 = 1
f2 = 2
f3 = 6

so im my oponion g1 = the answer of f1 which is also the max

But recall the problem definition:

4.21 Given a function f of type Integer -> Integer give a recursive definition of a
function of type Integer -> Integer which on input n returns the maximum
of the values f 0, f 1, ..., f n.

It doesn't say anything about f, which means you are not allowed to make assumptions about the definition of f.

f could be defined as:

  f :: Integer -> Integer
  f 42 = 100
  f x  = 0

Since you don't know anything about f, you must look at all values from f 0 to f n in order to find the maximum.

Regards,
Sean

Oke,

Now I see it.

Later on the exercise this is stated.

f 0 = 0
f 1 = 44
f 2 = 17
f _ = 0


So f0  gives 0 , f1 gives 44, f2 till fn gives also 44

Now I have to think about how to read the values of f 1 .. fn 2 . I think I need 2 recursive function . One for g x and one for reading f1 or use a list to store f 0  .. f n and then use maximum.

Roelof