Python and Lisp : car and cdr
Chris Angelico
rosuav at gmail.com
Sun Jun 19 09:23:10 EDT 2011
On Sun, Jun 19, 2011 at 10:56 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> Lie Ryan wrote:
>> def cdr(L):
>> return L[1]
>
> IANAL (I am not a Lisper), but shouldn't that be 'return L[1:]' ?
In LISP, a list is a series of two-item units (conses).
>> L = (a, (b, (c, (d, None))))
This represents the LISP equivalent of [a, b, c, d] in Python. A list
is a linked list, not an array (as in Python).
IANAL either though, someone else may wish to clarify the advantages
of this system.
ChrisA
More information about the Python-list
mailing list