Skip to content

Instantly share code, notes, and snippets.

@bjartek
Created September 14, 2010 06:40
Show Gist options
  • Save bjartek/578639 to your computer and use it in GitHub Desktop.
Save bjartek/578639 to your computer and use it in GitHub Desktop.
def join(list : List[Int]) : String = list match {
case List() => ""
case List(x) => x.toString
case List(x,y) => x + " and " + y
case List(x,y,z) => x + ", " + y + ", and " + z
case _ => list(0) + ", " + join(list.tail)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment