Skip to content

Instantly share code, notes, and snippets.

@agushuley
Created September 30, 2012 18:56
Show Gist options
  • Save agushuley/3808143 to your computer and use it in GitHub Desktop.
Save agushuley/3808143 to your computer and use it in GitHub Desktop.
Scala for impatients, chapter 4, 2th task
var frequency = new scala.collection.mutable.HashMap[String, Int]
def process( word: String ): Unit = {
frequency += ( word -> ( frequency.getOrElse( word, 0 ) + 1 ) )
}
var in = new java.util.Scanner( new java.io.File ( "/Users/andriy/tmp/myfile.txt" ) )
while ( in.hasNext ) process ( in.next )
println ( frequency )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment