Generator (computer programming): Difference between revisions

Content deleted Content added
m Fix Linter errors.
m Icon: syntaxhighlight
Line 74:
 
Printing squares from 0 to 20 can be achieved using a co-routine by writing:
<syntaxhighlight lang="icon">
<pre>
local squares, j
squares := create (seq(0) ^ 2)
Line 82:
else
break
</syntaxhighlight>
</pre>
 
However, most of the time custom generators are implemented with the "suspend" keyword which functions exactly like the "yield" keyword in CLU.