Created
December 16, 2020 17:26
-
-
Save xrrocha/de0fafc47845ee303d3453815e98ae9f to your computer and use it in GitHub Desktop.
code block for README-24
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
// Scramble from files/stdin to stdout | |
fun main(args: Array<String>) { | |
// Collect readers from args/stdin | |
val readers = | |
if (args.isNotEmpty()) | |
args.map { File(it).reader() } | |
else | |
// in: quoted because reserved | |
listOf(System.`in`.reader()) | |
// Swallow all readers into string | |
val content = | |
readers.joinToString("\n") { | |
// Reads entire file | |
it.readText() | |
} | |
// Scramble words and print to stdout | |
println(scrambleWords(content)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment