Last active
August 29, 2015 14:10
-
-
Save fsubal/da6e34c37de6da673cdc to your computer and use it in GitHub Desktop.
Get Most Frequent Strings from List[String]
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
// get most frequent Strings from the newest n values | |
def mostFrequent(l:List[String], n:Int): List[String] = { | |
val id = l.take(Math.min(list.length, i)).unzip._1.groupBy(identity) | |
val frq = id.maxBy(_._2.size)._2.size | |
id.filter(_._2.size == frq) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment