have [yield] return the args from subsequent coroutine invocations?
Posted to
tcl
by kbk at Fri Jul 18 20:49:44 GMT 2008
view raw
coroutine adder {n} {
set
sum
$n
while
{1} {
incr
sum [
lindex
[yield
$sum
] 0]
}
}
puts
[adder 1]; # prints 1
puts
[adder 2]; # prints 3
puts
[adder 3]; # prints 6
Recent Posts
tcl by FLORENTIS
1 days ago
tcl by Florentis
1 days ago
tcl by schelte
6 days ago
tcl by iobates
6 days ago
tcl by cgm
7 days ago
tcl by iobates
12 days ago
tcl by FM
16 days ago
tcl by FM
16 days ago
tcl by FM
16 days ago
tcl by FM
16 days ago
Submit
New paste
Documentation
From Jabber