Skip to content

Instantly share code, notes, and snippets.

@oconnor663
Created October 12, 2012 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oconnor663/3878147 to your computer and use it in GitHub Desktop.
Save oconnor663/3878147 to your computer and use it in GitHub Desktop.
nl.hs
import System.Environment
import Control.Monad
addNumbers strs = zipWith (\a b -> show a ++ " " ++ b) [1..] strs
main = do
args <- getArgs
text <- if length args > 0
then readFile (head args)
else getContents
putStr $ unlines $ addNumbers $ lines text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment