Skip to content

Instantly share code, notes, and snippets.

@joastbg
Last active December 26, 2015 21:09
Show Gist options
  • Select an option

  • Save joastbg/7213812 to your computer and use it in GitHub Desktop.

Select an option

Save joastbg/7213812 to your computer and use it in GitHub Desktop.
Haskell - playing with command-line arguments using forM_ and mapM_
module Main where
import System.Environment
import Control.Monad
main :: IO ()
main = do
args <- getArgs
putStrLn ("Hello, " ++ args !! 0)
-- using for
forM_ args $ \arg -> putStrLn $ show arg
-- using map
mapM_ (\arg -> putStrLn $ show arg) args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment