Implements wordOccurrences

This commit is contained in:
julien lengrand-lambert
2017-04-19 14:27:14 +02:00
parent f02e4f8cfd
commit 688868035c

View File

@@ -34,7 +34,7 @@ object Anagrams {
*
* Note: you must use `groupBy` to implement this method!
*/
def wordOccurrences(w: Word): Occurrences = ???
def wordOccurrences(w: Word): Occurrences = w.toLowerCase().groupBy(c => c).map{ case(k, v) => (k, v.length)}.toList.sorted
/** Converts a sentence into its character occurrence list. */
def sentenceOccurrences(s: Sentence): Occurrences = ???