Created
September 15, 2016 19:21
-
-
Save programaths/505b5eafd8809a93e9a1d9a2dacdf315 to your computer and use it in GitHub Desktop.
A functional line count.
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
import java.io.File | |
fun main(args: Array<String>) { | |
args.map { name -> File(name) } | |
.filter { file -> file.isFile } | |
.map { file -> Pair(file.name, file.readLines().partition { line -> line.trim().isEmpty() }) } | |
.forEach { | |
val name = it.first | |
val (filledLines,emptyLines) = it.second | |
println("$name: ${filledLines.size+emptyLines.size} total, ${emptyLines.size} empty") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment