[Haskell-beginners] making function problem (chapter 6 of Programming in Haskell)
Roelof Wobben
rwobben at hotmail.com
Mon Aug 8 20:58:36 CEST 2011
----------------------------------------
> Date: Mon, 8 Aug 2011 19:18:55 +0100
> From: dbeacham at dbeacham.co.uk
> To: beginners at haskell.org
> Subject: Re: [Haskell-beginners] making function problem (chapter 6 of Programming in Haskell)
>
> On 08/08/11 16:17, Ertugrul Soeylemez wrote:
> >> > Maybe this :
> >> >
> >> > x ^ 0 = 1
> >> > x ^ y = x * (y-1)
> Hi Roelof,
>
> I don't think you're far away - it could just be a typo/lack of care in
> writing it down. Have you tried putting some actual values into these
> rules? - that should help you understand what is wrong with what you've
> written down/get you closer to the correct solution.
>
> For example: (x=2, y=4) 2^4 = 16 != 6 = 2 * 3
>
> David.
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
Oke,
what Im trying to say it this :
2 ^ 4
= 2 * 2 ^ 3
= 2 * 2 * 2 ^ 2
= 2 * 2 * 2 * 2 ^ 1
= 2 * 2 * 2 * 2 * 2 ^ 0
So the y is on each number one less on each run.
So maybe it's x ^ y = x * x ^ y
Roelof
More information about the Beginners
mailing list