harryo / zipworld.com.au (Harry Ohlsen) wrote: > > >... I find the idea of a function returning > >a succession of values to be 'clean', 'aesthetically pleasing' etc -- > >i.e reasons hard to rationalise. I've nothing against yield, by the way. > >Also, this is very hard to do without such a feature, because you need >to keep static copies of everything that has changed during the >current call. I disbelieve that it is that hard. Just use a closure: sub fib_generator (x=0, y=1) proc {|| x, y = y, x+y; return y} end What might be nice though is a way to turn a generator like this into an infinite array. (OK, as an array we might want to start with y=0 and x=1...) That will be trivially done once we have the right module to mixin. >This idea isn't just in Icon. It's in Prolog, too, and probably a >number of other "logic" languages (rg Mercury). > Cheers, Ben _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com