On Tue, Jun 3, 2008 at 6:48 PM, Ronald Guida <[EMAIL PROTECTED]> wrote:
> filter (\x -> case x of A -> True; otherwise -> False) sampleTypes
> ==> [A]
>
> filter (\x -> case x of B _ -> True; otherwise -> False) sampleTypes
> ==> [B 5]
There's a neat little mini-trick for these types of pattern matches:
filter (\x -> case x of B {} -> True; otherwise -> False) sampleTypes
Does the same thing, but works no matter how many arguments the
constructor B takes.
Luke
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe