Problem in code

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem in code

Jenny678
hello,
I can not find the problem, I use WinHugs and shows me(Syntax error in input (unexpected keyword "where").
here is my code:

f :: (Float,Float) -> Float
f (x,y) = (a(x,y) + 4) * (b(x,y) + 3)
where
a :: (Float,Float) -> Float
a(x,y) = (x + y)*2
b :: (Float,Float) -> Float
b(x,y) = (y - x)*5

How can I define this code with let in?
Thanks for any help.
Reply | Threaded
Open this post in threaded view
|

Re: Problem in code

Neil Mitchell
Hi,

Haskell is based on indentation for grouping, so your code is fine,
you just need to indent the lines marked:

> f :: (Float,Float) -> Float
> f (x,y) = (a(x,y) + 4) * (b(x,y) + 3)
>     where
>     a :: (Float,Float) -> Float
>     a(x,y) = (x + y)*2
>     b :: (Float,Float) -> Float
>     b(x,y) = (y - x)*5

You can do it with let, but there is no need.

Thanks

Neil
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe