[Haskell-beginners] making function problem (chapter 6 of Programming in Haskell)

Roelof Wobben rwobben at hotmail.com
Mon Aug 8 16:53:30 CEST 2011




----------------------------------------
> To: beginners at haskell.org
> From: es at ertes.de
> Date: Mon, 8 Aug 2011 16:36:18 +0200
> Subject: Re: [Haskell-beginners] making function problem (chapter 6 of Programming in Haskell)
>
> Roelof Wobben <rwobben at hotmail.com> wrote:
>
> > I think you mean something like this :
> >
> > 2 ^ 3 =
> > = 2 * 2 ^ 2
> > = 2 * 2 * 2 ^1
> > = 2 * 2 * 2 * 2 ^ 0
> > = 2 * 2 * 2 * 1
> > = 2 * 2 * 2
> > = 4 * 2
> > = 8
>
> Yes, but that's not a rule system. Try to come up with a rule system to
> express exponentiation. You need two rules for the algorithm you want
> to implement.
>
>
> Greets,
> Ertugrul
>
>
> --
> nightmare = unsafePerformIO (getWrongWife >>= sex)
> http://ertes.de/
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners


Maybe this :

 

x ^ 0 = 1 

x ^ y = x * (y-1) 

 

Roelof

  		 	   		  


More information about the Beginners mailing list