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

Roelof Wobben rwobben at hotmail.com
Tue Aug 9 14:16:52 CEST 2011




----------------------------------------
> Date: Mon, 8 Aug 2011 14:59:39 -0700
> From: kc1956 at gmail.com
> To: beginners at haskell.org
> Subject: Re: [Haskell-beginners] making function problem (chapter 6 of Programming in Haskell)
>
> Hint
>
> positivePower :: Int -> Int -> Int
> positivePower x 1 = x
> positivePower x y = dododoo positivePower yadayada
>
>
> --
> --
> Regards,
> KC
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners


oke.

 

I see it

 

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.

PostivePower x y =  x + postivePower x y 

 

for example 

 

x = 4 

y = 3 

 

4 * 3 = 

4 + 4 * 2 

4 + 4 + 4 * 1 

4 + 4 + 4 

4 + 8 

12 

 

 

Roelof

  		 	   		  


More information about the Beginners mailing list