Re: How can I create a linked list in Python?
sturlamolden a écrit :
sturlamolden a écrit :
Bruno Desthuilliers wrote:
>
>
>
>
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.
>
>
>
>
>
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.
>
>
>
>>Have you considered using tuples ? If you go the FP way, why not use an
>>immutable type ?
>>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.
>
Comment