
31 Mar
2009
31 Mar
'09
3:53 a.m.
That works, but I guess a case statement would be nicer: case compare r 0 of LT -> LEFT GT -> RIGHT EQ -> STRAIGHT This uses the compare function, which results in a value of the Ordering datatype, which consists of the constructors LT, EQ and GT. Peter Hickman wrote:
I've just written this piece of code
if r < 0 then LEFT else if r > 0 then RIGHT else STRAIGHT
which works just fine but it does look rather clunky (as it would in any language I suppose). Is there a Haskell idiom for this type of code?
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners