Re: turing machine in an LC

2005-02-10 Thread Sion Arrowsmith
Greg Ewing <[EMAIL PROTECTED]> wrote: >As a fellow named Church once pointed out, lambdas are really >*all* you need in a language... ... where as others argue that it is impractical not to have some form of runtime data storage, thereby giving rise to the separation of Church and state. -- \S

Re: turing machine in an LC

2005-02-09 Thread Greg Ewing
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

Re: A ListComp that maintains its own state (Was: Re: turing machine in an LC)

2005-02-08 Thread Michael Spencer
Carl Banks wrote: Pay attention, chief. I suggested this days ago to remove duplicates from a list. from itertools import * [ x for (x,s) in izip(iterable,repeat(set())) if (x not in s,s.add(x))[0] ] ;) Sorry, I gave up on that thread after the first 10 Million* posts. Who knows what other pe

Re: A ListComp that maintains its own state (Was: Re: turing machine in an LC)

2005-02-08 Thread Carl Banks
Michael Spencer wrote: > > Jeremy Bowers <[EMAIL PROTECTED]> writes: > > > > > >>On Tue, 08 Feb 2005 17:36:19 +0100, Bernhard Herzog wrote: > >> > >>>Nick Vargish <[EMAIL PROTECTED]> writes: > >>> > "Xah Lee" <[EMAIL PROTECTED]> writes: > > >is it possible to write python code without

A ListComp that maintains its own state (Was: Re: turing machine in an LC)

2005-02-08 Thread Michael Spencer
Jeremy Bowers <[EMAIL PROTECTED]> writes: On Tue, 08 Feb 2005 17:36:19 +0100, Bernhard Herzog wrote: Nick Vargish <[EMAIL PROTECTED]> writes: "Xah Lee" <[EMAIL PROTECTED]> writes: is it possible to write python code without any indentation? Not if Turing-completeness is something you desire. Ber

Re: turing machine in an LC

2005-02-08 Thread Jeremy Bowers
On Tue, 08 Feb 2005 20:47:06 +0100, Bernhard Herzog wrote: > [x for L in [[[initial_state, 0]]] >for state, pos in L >if state is not None > and (L.append([M[state][T.get(pos, 0)][2], > pos + M[state][T.get(pos, 0)][1]]) >or T._

Re: turing machine in an LC

2005-02-08 Thread Bernhard Herzog
Jeremy Bowers <[EMAIL PROTECTED]> writes: > On Tue, 08 Feb 2005 17:36:19 +0100, Bernhard Herzog wrote: >> Nick Vargish <[EMAIL PROTECTED]> writes: >>> "Xah Lee" <[EMAIL PROTECTED]> writes: is it possible to write python code without any indentation? >>> Not if Turing-completeness is something

Re: turing machine in an LC

2005-02-08 Thread Michael Spencer
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: >>> resul

Re: turing machine in an LC

2005-02-08 Thread Michael Spencer
Jeremy Bowers wrote: That's not a generator expression, that's a generator function. Nobody contests they can reference earlier states, that's most of their point :-) Are you sure? I just wrote my examples in functions to label them Here's your example with this method: >>> import itertools as it

Re: turing machine in an LC

2005-02-08 Thread Jeremy Bowers
On Tue, 08 Feb 2005 10:50:24 -0800, Michael Spencer wrote: > 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 > ... >

Re: turing machine in an LC

2005-02-08 Thread Jeremy Bowers
On Tue, 08 Feb 2005 10:24:28 -0800, Michael Spencer wrote: > 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 "

Re: turing machine in an LC

2005-02-08 Thread Michael Spencer
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

Re: turing machine in an LC

2005-02-08 Thread Michael Spencer
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 whic