Skip to content

Instantly share code, notes, and snippets.

@tonyslowdown
Last active June 3, 2017 19:17
Show Gist options
  • Save tonyslowdown/b0a7acdde17b377c96561cd52ff4be9f to your computer and use it in GitHub Desktop.
Save tonyslowdown/b0a7acdde17b377c96561cd52ff4be9f to your computer and use it in GitHub Desktop.
Scala combinations
def comb[T](l: List[T]): List[List[T]] = l match {
case Nil => List(Nil)
case x::xs => {
val prevResult = comb(xs)
prevResult ++ prevResult.map(y => x::y)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment