-
-
Save valtih1978/5983b7620798beeda317 to your computer and use it in GitHub Desktop.
small fix
This file contains hidden or 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
//forked from https://gist.github.com/jkdeveyra/4030815 | |
def sentenceAnagrams(sentence: Sentence): List[Sentence] = { | |
def subSentence(occ: Occurrences): List[Sentence] = { | |
if (occ.isEmpty) List(List()) | |
else | |
for { | |
x <- combinations(occ) | |
y <- dictionaryByOccurrences.getOrElse(x, List()) | |
z <- subSentence(subtract(occ, x)) | |
} yield y :: z | |
} | |
subSentence(sentenceOccurrences(sentence)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment