Jump to content

Loops/Continue: Difference between revisions

Line 380:
 
===Using list===
<lang ela>open consolemonad imperativeio
loop [] = return ()
loop (x::xs) = rec (write << show) x c `seq` loop xsdo
putStr (show x)
where c | x % 5 == 0 = "\r\n"
putStr f
| else = ", "
loop xs
where cf | x % 5 == 0 = "\r\n"
| else = ", "
_ = loop [1..10] ::: IO</lang>
 
This version is more generic and can work for any given range of values.
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.