[Haskell-beginners] Problem with defining functions and guarded rules

This is still my display name xning_90 at hotmail.com
Mon Jul 25 07:38:40 CEST 2011


Hi, I just started learning Haskell. But I have been having a problem with defining functions. For example,diff :: Float-> Float  diff = if x>= y then x-y else y-x<interactive>:1:29: parse error on input `='It is rather weird as I have checked quite a few websites and this was supposed to work.The same occurs when I try for guarded rules, except that it is now for |.diff :: Float -> Float -> Floatdiff x y | x >= y = x - y| otherwise = y - x<interactive>:1:42: parse error on input `|'Please do help!Thanks a lot. 		 	   		   		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110725/4858ef6b/attachment.htm>


More information about the Beginners mailing list