Created
November 10, 2012 12:16
-
-
Save lisongx/4050902 to your computer and use it in GitHub Desktop.
fp week6
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 sentenceAnagrams(sentence: Sentence): List[Sentence] = { | |
def sen_iter(occur: Occurrences): List[Sentence] = { | |
if (occur == List()) | |
List(Nil) | |
else for { | |
word_occur <- combinations(occur).filter(_ != List()) | |
word <- dictionaryByOccurrences(word_occur) | |
rest <- sen_iter(subtract(occur, word_occur)) | |
} yield word :: rest | |
} | |
val s_occurs = sentenceOccurrences(sentence) | |
sen_iter(s_occurs) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment