Re: NRE committed: PLEASE TEST




This is a very nice addition to tcl but its way to complex for me to
use. I need some sugar and I'm not sure how to write it. What I want
is a "generator" command which I can use to create different types of
generators, like iota:

generator iota { start end incr } {
for { set i $start } { $i <= $end } { incr $incr } { yield $i }
}

Then I might use it like this:

while { [set x [iota 2 20]] } { puts $x }

With the generator yielding 18 times and then returning "break". I
don't want to know about apply and other functional theory. I also
don't want to have to create a place holder token to hold the
coroutine. I know how I want to use coroutines and I don't want to
know all this other stuff.

Is an API like this possible?

.



Relevant Pages

  • Re: ANN: Generator package version 0.1
    ... This coroutine is the generator. ... The foldr version is right-associative: ... The generator package provides both, but the foldl version is much more efficient in Tcl as it can traverse the generator in-order, computing the result as it goes. ... The reason for this appears to be that the overhead of a coroutine context-switch in Tcl currently is quite high. ...
    (comp.lang.tcl)
  • Building my Co2 generator
    ... should I use for the yeast and sugar for this size generator? ...
    (rec.aquaria.freshwater.plants)