MonkeeSage wrote: > > def cons(car,cdr): return (car,cdr) # or [car,cdr] > > def car(cons): return cons[0] > > def cdr(cons): return cons[1] > > I guess you were talking about implementing the _structure_ of lisp > lists in python syntax (as you seem to imply), not trying to emulate > their _behavior_ with one-dimensional python lists.
The original poster was asking about using Python for teaching data structures and algorithms, and the implementation details of Python lists in particular. It may not be obvious that they are essentially arrays under the hood. The Lisp discussion became a digression; I was not trying to implement Lisp in Python, but rather demonstrate the difference between Lisp lists and Python lists. -- http://mail.python.org/mailman/listinfo/python-list