[Haskell-beginners] Pattern Matching

Alex Watt el.zingo at gmail.com
Sat Aug 2 22:09:24 EDT 2008


Hi there,

The best way I can explain what I'd like to do is show an example, so here
goes:

same :: a -> a -> Bool
same x x = True
same _ _ = False

Is there any way to do this in Haskell? The actual reason I'd like to do
this is something slightly more complicated. I want to match against a list
of elements, like so:

foo [x,x,x] = ...

Thanks for any help.

- Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20080803/adb7448b/attachment.htm


More information about the Beginners mailing list