[Haskell-beginners] 'case of' question
Manfred Lotz
manfred.lotz at arcor.de
Thu Jun 23 17:02:31 CEST 2011
Hi there,
Let's say I have something like this (it is an artificial example just
for illustration):
case x of
1 -> doThis
5 -> doThis
76 -> doThis
112 -> doThat
21 -> doThat
_ -> doOtherwise
I would like to have something like this (which is illegal)
case x of
1 | 5 | 76 -> doThis
112 | 21 -> doThat
_ -> doOtherwise
Is something like this possible to do?
The only idea I got is:
processX x
| x `elem` [ 1, 5, 76 ] = doThis
| x `elem` [ 112, 21 ] = doThat
| otherwise = doOtherwise
--
Manfred
More information about the Beginners
mailing list