Created
September 25, 2012 08:18
-
-
Save jkao/3780603 to your computer and use it in GitHub Desktop.
Get all Unique Sequences
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 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