
21 Sep
2002
21 Sep
'02
10:42 p.m.
On Sat, Sep 21, 2002 at 12:56:13PM -0700, Russell O'Connor wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
[To: haskell-cafe@haskell.org]
Is there a nicer way of writing the following sort of code?
case (number g) of Just n -> Just (show n) Nothing -> case (fraction g) of Just n -> Just (show n) Nothing -> case (nimber g) of Just n -> Just ("*"++(show n)) Nothing -> Nothing
You could write (using GHC's pattern guards): show g | Just n = number g = Just (show n) | Just n = fraction g = Just (show n) | Just n = nimber g = Just ("*"++show n) | Nothing = Nothing Do I detect a program for analyzing combinatorial games being written? --Dylan