Skip to content

Instantly share code, notes, and snippets.

@fsubal
Last active August 29, 2015 14:10
Show Gist options
  • Save fsubal/da6e34c37de6da673cdc to your computer and use it in GitHub Desktop.
Save fsubal/da6e34c37de6da673cdc to your computer and use it in GitHub Desktop.
Get Most Frequent Strings from List[String]
// 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