[Haskell-beginners] making function problem (chapter 6 of Programming in Haskell)
Roelof Wobben
rwobben at hotmail.com
Tue Aug 9 14:44:06 CEST 2011
----------------------------------------
> Subject: Re: [Haskell-beginners] making function problem (chapter 6 of Programming in Haskell)
> From: ds at iai.uni-bonn.de
> To: rwobben at hotmail.com
> CC: beginners at haskell.org
> Date: Tue, 9 Aug 2011 14:41:13 +0200
>
> Hi Roelof,
>
> On Tue, 2011-08-09 at 12:16 +0000, Roelof Wobben wrote:
> > oke.
> >
> >
> >
> > I see it
> >
> unfortunately its still not true. Your example with the concrete numbers
> is right, and it captures the scheme well. But try to check your code
> with it. I'd like to say its typos, but its actually the same typos as
> you had for the actual main example, calculating the lists.
> Try to answer the questions I ask below and then use the answers for a
> correct definition (that is very similar to the recent one).
> >
> >
> > I'm going for this :
> >
> >
> >
> > postivePower :: Int -> Int -> Int
> >
> > PostivePower x 1 = 1 because when you multiply something by one is
> > remains the same value.
> Does this really return the value you want? Is 5 * 1 = 1 ?
> >
> > PostivePower x y = x + postivePower x y
> >
> Do you really want to call positivePower with the same y again, or more
> concretely: Is 4 * 3 = 4 + (4 * 3)?, or should there be a "2" somewhere?
>
It should be 2 so it would then be postivepower x y = x + postivepower x (y-1)
Roelof
More information about the Beginners
mailing list