How can I create a linked list in Python?
sturlamolden
sturlamolden at yahoo.no
Wed Jan 17 17:53:02 EST 2007
Bruno Desthuilliers wrote:
> Have you considered using tuples ? If you go the FP way, why not use an
> immutable type ?
Well, good question. Tuples are immutable, which means they are
immutable. So you cannot use a cursor to change an element inside the
list. So instead of changing the original items, you just replace the
cursor with a new reference. But it it is read only, sure, use tuples.
> But how are Lisp lists implemented then ?-)
They are defunct binary trees, some think they are not really lists at
all :-)
Actually, nesting tuples or lists doesn't really duplicate Lisp cons,
as one can only create a stack-like object with the nesting. Python
really need a cons type like Lisp. I think it is time to write one, in
a plain C extension.
More information about the Python-list
mailing list