On Thu, Jul 17, 2003 at 12:03:19PM +0100, Bayley, Alistair wrote:
> This is what I've turned it into to get it to work. It seems a bit clumsy;
> is there a better way to write this?
> 
> > test n =
> >     case True of
> >             _ | n == one -> "one"
> >               | n == two -> "two"
> >               | otherwise -> "three"

Or you might want to use something like this:
(depending on how much your example resembles the actual code
and the number of variables you want to match)

module Main where

one         = 1
two         = 2

test n      = maybe d id (n `lookup` m)
    where
        m   = [(one,    "one")
              ,(two,    "two")
              ]
        d   = "three"
-- 
Nobody can be exactly like me. Even I have trouble doing it.

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to