Last active
December 26, 2015 21:09
-
-
Save joastbg/7213812 to your computer and use it in GitHub Desktop.
Haskell - playing with command-line arguments using forM_ and mapM_
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
| 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