Re: Case expressions, matching, and "constants"

17 Jul
2003
17 Jul
'03
1:52 p.m.
At 12:03 17/07/03 +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"
The 'case' is somewhat redundant. How about:
test n | n == one = "one" | n == two = "two" | otherwise = "three"
#g
-------------------
Graham Klyne
8027
Age (days ago)
8027
Last active (days ago)
0 comments
1 participants
participants (1)
-
Graham Klyne