PinkiePie-Z
PinkiePie-Z

Reputation: 553

How to use case expression for tuple in Haskell?

I have a problem when using case expression in Haskell.

filterSth::[a]->(b,c)->[a]
filterSth (x:xs) (b, c) =
    case (b,c) of
        (1,0) -> ...
        (1,2) -> ...
        ...

can I do something like above ?

Upvotes: 1

Views: 1801

Answers (1)

sepp2k
sepp2k

Reputation: 370367

Yes, you can do something like the above except that b and c need to have a numeric type if you want to pattern match them against numeric constants.

Upvotes: 5

Related Questions