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

Daniel Seidel ds at iai.uni-bonn.de
Tue Aug 9 14:41:13 CEST 2011


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?

>  
> 
> for example 
> 
>  
> 
> x = 4 
> 
> y = 3 
> 
>  
> 
> 4 * 3 = 
> 
> 4 + 4 * 2 
> 
> 4 + 4 + 4 * 1 
> 
> 4 + 4 + 4 
> 
> 4 + 8 
> 
> 12 
> 




More information about the Beginners mailing list