Created
          December 26, 2014 05:52 
        
      - 
      
- 
        Save ostretsov/ccd4f3d0b12bb3e5542c to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or 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 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