PEP 255: Simple Generators

Paul Foley see at below
Wed Jun 20 23:03:39 EDT 2001


On 20 Jun 2001 18:05:40 +0200, Denys Duchier wrote:

> While possibly aberrant, let me suggest a higher-order programming
> approach that would not even require a new keyword but merely a new
> primitive which I'll call `generator'.  This primitive takes a unary
> procedure as argument and returns an iterator.  The unary procedure
> takes itself a `yield' procedure as argument.  Here is the fib example
> of the PEP written with my proposal:

> 	def fib(yield):
> 	  a, b = 0, 1
> 	  while 1:
> 	    yield(b)
> 	    a, b = b, a+b
	
> 	g=generator(fib)

Check out http://www.math.uio.no/cltl/clm/node362.html and node347.html

-- 
For thæm se the his cræft forlætt, se bið fram thæm cræfte forlæten.
                                                                -- Ælfric
(setq reply-to
  (concatenate 'string "Paul Foley " "<mycroft" '(#\@) "actrix.gen.nz>"))



More information about the Python-list mailing list