Created
February 1, 2015 10:35
-
-
Save quii/339502e477d3dc5818fe to your computer and use it in GitHub Desktop.
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
object LetterCounter extends App{ | |
val filters = args.lift(1).getOrElse("aeiou").toList | |
val grouped = args(0).groupBy(l=>l).collect{case (l,g) => (l, g.length)} | |
val groupCount = filters.map(v => grouped.find(x=> x._1==v).getOrElse((v,0))) | |
val output = groupCount.foldLeft("")((result, pair) => result+pair._1 + ": "+pair._2+" ") | |
println(output) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment