Generator/Exponential: Difference between revisions
Content added Content deleted
mNo edit summary |
(→{{header|Tcl}}: Tart up) |
||
Line 8: | Line 8: | ||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
{{works with|Tcl|8.6}} |
{{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 |
<lang tcl>package require Tcl 8.6 |
||
Line 33: | Line 34: | ||
}} squares cubes |
}} squares cubes |
||
# Drop 20 |
|||
for {set i 0} {$i<20} {incr i} {filtered} |
for {set i 0} {$i<20} {incr i} {filtered} |
||
# Take/print 10 |
|||
for {} {$i<30} {incr i} { |
for {} {$i<30} {incr i} { |
||
puts [filtered] |
puts [filtered] |