Loops/Continue: Difference between revisions

no edit summary
No edit summary
Line 233:
 
</lang>
 
=={{header|Ela}}==
 
===Direct Approach===
 
<lang ela>open Con
 
let loop n | n > 10 = ()
| else = rec write n f $ loop (n+1)
where f | n % 5 == 0 = "\r\n"
| else = ", "
 
loop 1</lang>
 
Function rec creates a cyclic version of a given function, it is defined in standard Prelude as 'let rec f x = f x $ rec f' where '$' is a sequencing operator.
 
===Using list===
 
<lang ela>open Con
 
let loop [] = ()
loop (x::xs) = rec write x c $ loop xs
where c | x % 5 == 0 = "\r\n"
| else = ", "
 
loop [1..10]</lang>
 
This version is more generic and can work for any given range of values.
 
=={{header|Factor}}==
Anonymous user