Created
          April 13, 2012 15:14 
        
      - 
      
 - 
        
Save carlobaldassi/2377574 to your computer and use it in GitHub Desktop.  
    greedy wc test
  
        
  
    
      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
    
  
  
    
  | function reallygreedylinecounter(fname::String) | |
| f = open(fname) | |
| return reallygreedylinecounter(f) | |
| end | |
| function reallygreedylinecounter(f::IOStream) | |
| try | |
| seek(f, 0) | |
| end | |
| ln = 0 | |
| eof = int(typemax(Uint32)) #argh | |
| while (c = ccall(:ios_getc, Int, (Ptr{Void},), f.ios)) != eof | |
| if c == '\n' | |
| ln += 1 | |
| end | |
| end | |
| return ln | |
| end | |
| wcbasedlinecounter(fname::String) = integer(split(readall(`wc -l $fname`),' ',false)[1]) | 
There, I fixed it ;)
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Why not just call it
wc? Afaik, there's no name clash since the otherwcis an executable.