Last active
June 3, 2017 19:17
-
-
Save tonyslowdown/b0a7acdde17b377c96561cd52ff4be9f to your computer and use it in GitHub Desktop.
Scala combinations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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