Skip to content

Instantly share code, notes, and snippets.

@ryanmr
Created March 19, 2016 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanmr/cf551582130842173d09 to your computer and use it in GitHub Desktop.
Save ryanmr/cf551582130842173d09 to your computer and use it in GitHub Desktop.
def split():(Deck, Deck) = {
val s = size()
val h = s / 2
val d1 = new Deck()
val d2 = new Deck()
for (i <- 1 to s) {
getCard() match {
case Some(card) => {
if (i < h) {
d1.addCard(card)
} else {
d2.addCard(card)
}
}
case None => {} // nothing
}
}
return (d1, d2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment