Generator/Exponential: Difference between revisions

mNo edit summary
Line 8:
=={{header|Tcl}}==
{{works with|Tcl|8.6}}
Tcl implements generators in terms of coroutines. If these generators were terminating, they would finish by doing <code>return -code break</code> so as to terminate the calling loop context that is doing the extraction of the values from the generator.
<lang tcl>package require Tcl 8.6
 
Line 33 ⟶ 34:
}} squares cubes
 
# Drop 20
for {set i 0} {$i<20} {incr i} {filtered}
# Take/print 10
for {} {$i<30} {incr i} {
puts [filtered]
Anonymous user