
11 Nov
2010
11 Nov
'10
12:24 p.m.
On Thursday 11 November 2010 18:03:10, C K Kashyap wrote:
Hi, I'd like to do something like this -
Instead of doing this -
f x = case x of 1 -> "One" 2 -> "Two"
I'd like to do this -
v1 = 1 v2 = 2
f x = case of v1 -> "One" v2 -> "Two"
Is that possible?
No, case does a pattern match, it checks whether the expression matches the pattern (patterns are defined in the report, section 3.17, http://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-580003.17), so variable names (identifiers beginning with a lower case letter) match everything.