We want to be able to pick nine random cards from an array of twelve cards, but can run into problems of keeping both the cards already draw and the cards left to draw from. Tracking two bits of state like this can create some hard to maintain argument gymnastics when creating our functions. Luckily we have a datatype Pair
at our disposal that allows us to combine two values in to one value.
We will use this Pair
type to model both a draw pile and a remaining pile, and take advantage of a couple special properties of Pair
that will allow us to combine two Pair
instances in a meaningful way by chain
ing. Just like we have done time and time again with the State
ADT