Is there an easier way to use guards in an expression...
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Mon Nov 10 19:43:28 EST 2003
W liście z pon, 10-11-2003, godz. 17:56, Graham Klyne pisze:
> mapL2V = \s ->
> case s of
> s | matchT s -> Just True
> | matchF s -> Just False
> | otherwise -> Nothing
Why not this?
mapL2V = \s ->
if matchT s then Just True else
if matchF s then Just False else
Nothing
> And a supplementary question... do the prelude or standard libraries define
> any function like this:
>
> cond :: Bool -> a -> a -> a
> cond True a _ = a
> cond False _ b = b
No. But if it's fully applied, 'if cond then a else b' seems to be as
clear.
--
__("< Marcin Kowalczyk
\__/ qrczak at knm.org.pl
^^ http://qrnik.knm.org.pl/~qrczak/
More information about the Haskell-Cafe
mailing list