Jeremy Bowers wrote:
On Tue, 08 Feb 2005 17:36:19 +0100, Bernhard Herzog wrote:


Now you *can* get at the previous state and write a state-transition expression in perfectly legal Python.

What do you know, generator comprehensions are Turing Complete and list
comprehensions aren't. I wouldn't have expected that.

I see no difference between LCs and GEs in this respect:

 >>> import itertools as it
 >>>
 >>> def fact_ge(n):
 ...     f = [1]
 ...     f.extend(i*j for i,j in it.izip(xrange(1,1+n), f))
 ...     return f
 ...
 >>> def fact_lc(n):
 ...     f = [1]
 ...     [f.append(i*j) for i,j in it.izip(xrange(1,1+n), f)]
 ...     return f
 ...
 ...
 >>> fact_ge(10)
[1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800]
 >>> fact_lc(10)
[1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800]

Michael



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to