Questions on Using Python to Teach Data Structures and Algorithms

MonkeeSage MonkeeSage at gmail.com
Fri Sep 29 00:17:38 EDT 2006


sturlamolden wrote:
> Thus I stand by my original claim. Essentlially:
>
> 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. That makes sense,
and your code is correct in that case; but in the other case Brendon's
code is correct. So everyone was right (only, about different things).
:)

Regards,
Jordan




More information about the Python-list mailing list