[Haskell-cafe] what do I have to do exactlry with this exercises
Sean Leather
sean.leather at gmail.com
Fri Oct 30 06:46:08 UTC 2015
On Fri, Oct 30, 2015 at 8:40 AM, Roelof Wobben wrote:
> Op 30-10-2015 om 07:35 schreef Sean Leather:
>
> On Fri, Oct 30, 2015 at 8:20 AM, Roelof Wobben wrote:
>
>> Im self studing Haskell with the Craft o ffunctional programmimg of
>> Hutton.
>>
>> Now I see two exercises that I do not understand what is really the
>> purpose here.
>>
>
> Maybe a slight rewording of the instructions would help? (It helped me!)
>
> The two exercises are :
>>
>> 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. [...]
>>
>
> Given:
>
> f :: Integer -> Integer
>
> Define:
>
> g :: Integer -> Integer
> g n = ...
>
> such that g is defined recursively. g n returns the maximum of f 0, f 1,
> ..., f n.
>
>
> Thanks,
>
> But is the maxium not always the last answer.
>
Indeed, it is not.
So the max of g 1 = answer g1 ??
>
The value of g 0 is f 0. The value of g 1 is either f 0 or f 1, whichever
is greater. The value of g 2 is one of f 0, f 1, or f 2, whichever is
greatest. And so on.
Regards,
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20151030/f3c03c46/attachment.html>
More information about the Haskell-Cafe
mailing list