Loops/Do-while: Difference between revisions

(Add XPL0)
Line 235:
 
<lang ela>open console
loop n | n % 6 == 0 = out $ ()
| else = out $`seq` loop (n+1)
where out = (& writen n)</lang>
 
This implementation uses a thunk to represent a console output. Output is not done in the initialization of 'out' variable, it is done when 'out' calculation is forced by a '$seq' operator (sequencing operator).
loop n | n % 6 == 0 = out $ ()
| else = out $ loop (n+1)
where out = (& writen n)</lang>
 
This implementation uses a thunk to represent a console output. Output is not done in the initialization of 'out' variable, it is done when 'out' calculation is forced by a '$' operator (sequencing operator).
 
=={{header|Erlang}}==
Anonymous user