Loops/While: Difference between revisions

Added Haskell example
(Added Haskell example)
Line 15:
i /= 2;
}</pre>
 
=={{header|Haskell}}==
 
Introducing and especially updating a loop variable requires side effects. So it's simpler to just create a list of the required values, and then loop over it to print them. However, that doesn't really reflect the structure of the imperative solutions.
 
<pre>
mapM print $ takeWhile (>0) $ iterate (`div` 2) 1024
</pre>
 
=={{header|Java}}==
Anonymous user