Loops/Foreach: Difference between revisions

Content added Content deleted
Line 593: Line 593:
=={{header|Ela}}==
=={{header|Ela}}==
===Standard Approach===
===Standard Approach===
<lang ela>open console imperative
<lang ela>open monad io

each writen [1..10]</lang>
each [] = do return ()
each (x::xs) = do
Function 'each' is defined in imperative module as:
putStrLn $ show x
<lang ela>each f (x::xs) = f x $ each f xs
each _ [] = ()</lang>
each xs</lang>
This also can be accomplished using 'map':
<lang ela>open console list

_ = map writen [1..10]</lang>


===Alternate Approach===
===Alternate Approach===