Azolex wrote: > generators challenge > -------------------- > > define "limit" and "itially" > > so that > > limit(foo(x) for x in itially(bar)) > > works out the same as > > limit2(foo,bar) > > with > > def limit2(foo,bar) : > bar1 = foo(bar) > while bar != bar1 : > bar1,bar = foo(bar),bar1
oops, this should read bar1,bar = foo(bar1),bar1 sorry > return bar > > > Note : be careful with your choice of foo and bar, to prevent infinite > loops when the iterated value won't converge. > > To think of it, perhaps "abs(bar-bar1)>epsilon" would be more > appropriate than "bar != bar1" in the above loop - I can imagine > roundoff errors leading to tiny oscillations in the least significant > bits of an otherwise convergent computation. > > Best, az -- http://mail.python.org/mailman/listinfo/python-list