Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7980
| From | Teemu Likonen <tlikonen@iki.fi> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Python and Lisp : car and cdr |
| Date | 2011-06-19 19:38 +0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <87oc1tzsic.fsf@mithlond.arda> (permalink) |
| References | <franck-58760D.16453817062011@news.free.fr> <4dfd90de$1@dnews.tpgi.com.au> <mailman.144.1308488252.1164.python-list@python.org> <4dfdf896$0$30002$c3e8da3$5496439d@news.astraweb.com> <mailman.159.1308500442.1164.python-list@python.org> |
* 2011-06-19T12:20:32-04:00 * Terry Reedy wrote: > On 6/19/2011 9:24 AM, Steven D'Aprano wrote: >> No. Each cell in a Lisp-style linked list has exactly two elements, >> and in Python are usually implemented as nested tuples: >> >> (head, tail) # Annoyingly, this is also known as (car, cdr). >> >> where head is the data value and tail is either another Lisp-style >> list or a marker for empty (such as the empty tuple () or None). > It should be noted that the head element of any 'list' can also be a > list' (as with Python lists), Both the head and tail elements of a cons cell can refer to any Lisp objects. Cons cell is a general-purpose primitive data type but it is _often_ used to build lists and trees so the tail element often refers to another cons cell (or nil that terminates the list). Let's not forget that Lisp's program code itself is built on such trees of cons cells. Lisp code itself is represented in this primitive Lisp data type. That's why Lisp is so powerful in meta programming. It's trivial to use Lisp functions to create Lisp code.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python and Lisp : car and cdr Franck Ditter <franck@ditter.org> - 2011-06-17 16:45 +0200
Re: Python and Lisp : car and cdr Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-17 09:29 -0600
Re: Python and Lisp : car and cdr Nobody <nobody@nowhere.com> - 2011-06-18 15:34 +0100
Re: Python and Lisp : car and cdr Lie Ryan <lie.1296@gmail.com> - 2011-06-19 16:00 +1000
Re: Python and Lisp : car and cdr Ethan Furman <ethan@stoneleaf.us> - 2011-06-19 05:56 -0700
Re: Python and Lisp : car and cdr Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-06-19 13:24 +0000
Re: Python and Lisp : car and cdr Terry Reedy <tjreedy@udel.edu> - 2011-06-19 12:20 -0400
Re: Python and Lisp : car and cdr Teemu Likonen <tlikonen@iki.fi> - 2011-06-19 19:38 +0300
Re: Python and Lisp : car and cdr Hrvoje Niksic <hniksic@xemacs.org> - 2011-06-19 16:26 +0200
Re: Python and Lisp : car and cdr Chris Angelico <rosuav@gmail.com> - 2011-06-19 23:23 +1000
Re: Python and Lisp : car and cdr "Elias Fotinis" <efotinis@yahoo.com> - 2011-06-19 16:24 +0300
Re: Python and Lisp : car and cdr Ethan Furman <ethan@stoneleaf.us> - 2011-06-19 08:07 -0700
Re: Python and Lisp : car and cdr Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-06-19 11:36 -0700
csiph-web