Skip to content

Instantly share code, notes, and snippets.

@frgomes
Last active October 30, 2015 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frgomes/3c9f36123c9432d9b6a3 to your computer and use it in GitHub Desktop.
Save frgomes/3c9f36123c9432d9b6a3 to your computer and use it in GitHub Desktop.
Scala - Read file as Stream
def matches(text: String, is: InputStream = System.in): Int =
scala.io.Source.fromInputStream(is)
.getLines
.toStream
.map(line => if(line.contains(text)) 1 else 0)
.reduce(_ + _)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment