On Sat, Sep 21, 2002 at 12:56:13PM -0700, Russell O'Connor wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> [To: [EMAIL PROTECTED]]
> 
> 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

Attachment: msg02002/pgp00000.pgp
Description: PGP signature

Reply via email to