Skip to content

Instantly share code, notes, and snippets.

@lisongx
Created November 10, 2012 12:16
Show Gist options
  • Save lisongx/4050902 to your computer and use it in GitHub Desktop.
Save lisongx/4050902 to your computer and use it in GitHub Desktop.
fp week6
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