[Haskell-beginners] Loop

Sumit Sahrawat, Maths & Computing, IIT (BHU) sumit.sahrawat.apm13 at iitbhu.ac.in
Sat May 2 00:06:47 UTC 2015


The reply I gave before might be more helpful if you consider the fact that

    a >> b >> c

is equivalent to

    do a
       b
       c

You can then use

    forM_ [1..4] (\_ -> putStrLn "Test")

What this does is,

    1. map (\_ -> putStrLn "Test") on [1..4]
    2. Use sequence_ to combine those operations

The even shorter way is replicateM_ which works like replicate from
Data.List

On 2 May 2015 at 01:39, Marcin Mrotek <marcin.jan.mrotek at gmail.com> wrote:

> Ah, sorry, I forgot about replicateM_.
>
> Best regards,
> Marcin Mrotek
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>



-- 
Regards

Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150502/06c988f9/attachment-0001.html>


More information about the Beginners mailing list