Expose the size of card packs

This commit is contained in:
Sasha 2018-02-25 23:17:51 +01:00
parent c2a324b905
commit 786dfe4bb8

View file

@ -71,6 +71,9 @@ port f bits = f bits . fromEnum
contains :: Pack -> Card -> Bool
contains = port testBit
size :: Pack -> Int
size = popCount
add :: Pack -> Card -> Pack
add = port setBit
@ -106,7 +109,7 @@ shuffle l =
pair :: Card -> Pack -> Maybe (Pack, Pack)
pair card pack =
let sameMonthCards = sameMonth card `intersection` pack in
case popCount sameMonthCards of
case size sameMonthCards of
0 -> Just (add pack card, empty)
1 -> Just (difference pack sameMonthCards, add sameMonthCards card)
_ -> Nothing