[Haskell-cafe] what do I have to do exactlry with this exercises

Sean Leather sean.leather at gmail.com
Fri Oct 30 07:00:07 UTC 2015


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151030/2e0b9cd9/attachment.html>


More information about the Haskell-Cafe mailing list