Last active
October 30, 2015 13:12
-
-
Save frgomes/3c9f36123c9432d9b6a3 to your computer and use it in GitHub Desktop.
Scala - Read file as Stream
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
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