Skip to content

Instantly share code, notes, and snippets.

@sebnozzi
Created March 24, 2014 09:50
Show Gist options
  • Save sebnozzi/9737379 to your computer and use it in GitHub Desktop.
Save sebnozzi/9737379 to your computer and use it in GitHub Desktop.
Checking on properties of a sequence of cards
object CardQuestions {
case class Card(number: Int, color: String)
val cards = Seq(
Card(5, "red"),
Card(7, "red"),
Card(3, "black"))
// Do the cards all have the same color?
def haveSameColor(cards: Seq[Card], ifEmpty: Boolean = true): Boolean = {
???
}
// Do the cards all have the same number?
def haveSameNumber(cards: Seq[Card], ifEmpty: Boolean = true): Boolean = {
???
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment