Skip to content

Instantly share code, notes, and snippets.

@nobsun
Created November 26, 2012 15:05
Show Gist options
  • Save nobsun/4148676 to your computer and use it in GitHub Desktop.
Save nobsun/4148676 to your computer and use it in GitHub Desktop.
module Main where
import System.Environment
main :: IO ()
main = mapM_ numbering =<< getArgs
numbering :: FilePath -> IO ()
numbering f = putStr . unlines . zipWith number [1..] . lines =<< readFile f
number :: Int -> String -> String
number n l = rjustify 6 (show n) ++ ": " ++ l
where
rjustify w = reverse . take w . (++ repeat ' ') . reverse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment