[Haskell-beginners] about the pattern matching
Raeck Zhao
raeck at msn.com
Tue Dec 23 20:45:05 EST 2008
hi, good ... morning : )
I am just confused by the following code
> oneOnly :: [Int]
> oneOnly = [1]
> isOneOnly :: [Int] -> Bool
> isOneOnly oneOnly = True
> isOneOnly tester = False
what I want to do is to define a 'type' oneOnly as [1] and use it on
the pattern matching in function isOneOnly. But it does not work as
I expect:
When I type
isOneOnly [1]
it will be True which is the result I expect but for
is OneOnly [1,2]
the result keeps True, it seems the second pattern has been ignored,
I think I try to achieve the purpose in a wrong way, any suggestion?
Thanks and Merry Christmas
Best wishes,
Raeck
_________________________________________________________________
Send e-mail anywhere. No map, no compass.
http://windowslive.com/oneline/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_anywhere_122008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20081224/c0486455/attachment-0001.htm
More information about the Beginners
mailing list