Jeremy Bowers wrote:


I can't figure out how to write a TM in a Python List Comprehension
without one of either "variable binding" (so we can store the last symbol
list and manipulate it in the next iteration) or "recursive function" (to
express the whole tape as a recursive function), both of which require
statements. I can figure out how to write a single state transition, but
in a single LC I can't figure out how to feed the new state into the next
iteration; the previous values generated in the LC are, to my knowledge,
not accessible to the LC as it is running. (If they are, I *think* that
would indeed be enough.)
How about:

>>> def fact_ge(n):
...     f = [1]
...     f.extend(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]
>>>

as a "stateful" genexp?


Michael


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

Reply via email to