Skip to content

Instantly share code, notes, and snippets.

@jkao
Created September 25, 2012 08:18
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 jkao/3780603 to your computer and use it in GitHub Desktop.
Save jkao/3780603 to your computer and use it in GitHub Desktop.
Get all Unique Sequences
def getAllUniqueSequences(currentList: List[Int]) : List[List[Int]] = {
if (currentList.length == 0) // Base case
List()
else // General case
(List(List(currentList.head))
++ getAllUniqueSequences(currentList.tail).map(s => currentList.head :: s)
++ getAllUniqueSequences(currentList.tail))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment