Skip to content

Instantly share code, notes, and snippets.

@ostretsov
Created December 26, 2014 05:52
Show Gist options
  • Save ostretsov/ccd4f3d0b12bb3e5542c to your computer and use it in GitHub Desktop.
Save ostretsov/ccd4f3d0b12bb3e5542c to your computer and use it in GitHub Desktop.
import scala.io.Source
if (args.length > 0) {
val fileLines = Source.fromFile(args(0)).getLines().toList
val maxLengthLine = fileLines.reduceLeft((a, b) => {
if (a.length > b.length) a else b
}).length.toString().length
for (line <- fileLines) {
val spaces = " " * (maxLengthLine - line.length.toString().length)
println(spaces + line.length + " | " + line);
}
}
else
Console.err.println("At least one argument is needed!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment