Jeremy Bowers wrote:


OK then, I still don't quite see how you can build a Turing Machine in one
LC, but an LC and one preceding list assignment should be possible,
although the resulting list from the LC is garbage;

Not necessarily garbage - could be anything, say a copy of the results:

>>> results = [0]
>>> [(results.append(lastresult+1) or lastresult) for i, lastresult in it.izip(xrange(5),results)]
[0, 1, 2, 3, 4]
>>> # ok, missing the 5, but close!


I don't think the assignment is avoidable though.

I should clarify a point I made earlier

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

What I meant was that both LCs and GEs can reference their prior state in the same way. Of course, there is an important difference in that the LC returns its list as soon as it is executed whereas the executing the genexp returns an iterator that can delay the evaluation of all but the outer loop until its next() is called. This makes a genexp equivalent to (at least some) functions, and perhaps that was part of your point that I missed.


Michael

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

Reply via email to