Skip to content

Commit

Permalink
fix wordOccurrences
Browse files Browse the repository at this point in the history
  • Loading branch information
frankh committed May 7, 2013
1 parent ad1861d commit e0594b8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions forcomp/src/main/scala/forcomp/Anagrams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ object Anagrams {
* same character, and are represented as a lowercase character in the occurrence list.
*/
def wordOccurrences(w: Word): Occurrences = {
w.groupBy((elem:Char)=>elem.toLower).map((mapping)=>(mapping._1, mapping._2.length))
w.groupBy((elem:Char)=>elem.toLower).map((mapping)=>(mapping._1, mapping._2.length)).toList.sorted
}
/** Converts a sentence into its character occurrence list. */
def sentenceOccurrences(s: Sentence): Occurrences = wordOccurrences(s.mkString(''))
def sentenceOccurrences(s: Sentence): Occurrences = wordOccurrences(s.mkString(""))

/** The `dictionaryByOccurrences` is a `Map` from different occurrences to a sequence of all
* the words that have that occurrence count.
Expand Down

0 comments on commit e0594b8

Please sign in to comment.