Reputation: 67
Currently I have the Cards list,Now I want to show all the possible pairs of cards in another list.
For example: [(Card Club R2, Card Heart R3), (Card Club R2, Card Heart R4), (Card Club R2, Card Heart R5), (Card Club R2, Card Heart R6).........]
.
The total result might be 1326 different pairs
Upvotes: 0
Views: 191
Reputation: 7360
Just do
[ (c1, c2) | c1 <- allCards, c2 <- allCards, c1 /= c2 ]
But this will return 2652 pairs, as mentioned.
To restict this to 1326 pairs, either do as Zeta suggested or add Ord
to Card
:
[ (c1, c2) | c1 <- allCards, c2 <- allCards, c1 < c2 ]
Upvotes: 2