Loops/Continue: Difference between revisions
Content added Content deleted
m (→{{header|Oforth}}: Replace rem by mod) |
|||
Line 365: | Line 365: | ||
===Direct Approach=== |
===Direct Approach=== |
||
<lang ela>open |
<lang ela>open monad io |
||
loop n |
loop n = |
||
if n > 10 then do |
|||
| else = rec write (show n) f `seq` loop (n+1) |
|||
return () |
|||
⚫ | |||
else do |
|||
putStr (show n) |
|||
putStr f |
|||
⚫ | |||
loop (n + 1) |
|||
⚫ | |||
| else = ", " |
|||
⚫ | |||
Function rec creates a cyclic version of a given function, it is defined in imperative module as 'rec f x = f x `seq` rec f' where 'seq' is a sequencing operator. |
|||
===Using list=== |
===Using list=== |