mirror of
https://github.com/jlengrand/FunctionalProgrammingScalaCoursera.git
synced 2026-03-10 15:49:51 +00:00
Implements wordOccurrences
This commit is contained in:
@@ -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 = ???
|
||||
|
||||
Reference in New Issue
Block a user