[Haskell-cafe] foreach

Udo Stenzel u.stenzel at web.de
Wed Sep 13 04:53:38 EDT 2006


Lemmih wrote:
>  main = do
>    args <- getArgs
>    flip mapM_ args $ \arg ->
>      flip mapM_ [1..3] $ \n ->
>        putStrLn $ show n ++ ") " ++ arg

Or even:

main = do
    args <- getArgs
    putStr $ unlines [ show n ++ ") " ++ arg
                     | arg <- args, n <- [1..3] ]

I'm really at a loss trying to understand why some people seem to like
the imperative style.  In fact, most  of the time, the strings in the
code above are better replaced by Doc from Text.PrettyPrint.


Udo.
-- 
Worrying is like rocking in a rocking chair -- It gives
you something to do, but it doesn't get you anywhere.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20060913/5d885ec7/attachment.bin


More information about the Haskell-Cafe mailing list