Jorgen Grahn [EMAIL PROTECTED] wrote:
FWIW, I oppose the idea (paraphrased from further up the thread) that linked
lists and other data structures are obsolete and dying concepts, obsoleted
by Python and other modern languages.
99% of the time. a Python list is the right tool for the job,
On Wed, 17 Jan 2007 10:11:40 +0100, Marc 'BlackJack' Rintsch [EMAIL
PROTECTED] wrote:
In [EMAIL PROTECTED], bearophileHUGS
wrote:
In CPython they are dynamic arrays, they aren't lists. Try adding
elements at the beginning of a list compared to adding elements at the
beginning or in the
Paul Rubin wrote:
But that's what Lisp does too.
Ok, I may have to reread Paul Graham's book on ANSI Common Lisp then.
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-01-18, sturlamolden [EMAIL PROTECTED] wrote:
Paul Rubin wrote:
But that's what Lisp does too.
Ok, I may have to reread Paul Graham's book on ANSI Common Lisp
then.
Here's something silly I whipped up to play with.
r Lisp style singly-linked lists called llist.
def consp(o):
In [EMAIL PROTECTED], bearophileHUGS
wrote:
In CPython they are dynamic arrays, they aren't lists. Try adding
elements at the beginning of a list compared to adding elements at the
beginning or in the middle of a python list and you will see the
efficiency differences.
Python has a list type
Marc 'BlackJack' Rintsch:
Python has a list type without the s, it's a real list. Don't confuse
the *ADT list* with *linked lists* which are just one implementation of
the ADT list.
Right, I was mostly talking about (single/double) linked lists :-)
Bye,
bearophile
--
sturlamolden a écrit :
Bruno Desthuilliers wrote:
Implementing linked lists in Python is not a great deal - it just
doesn't make much sens.
It does make sence,
Oh Yec ?-)
sorry...
as there are memory constraints related to it.
Python lists are arrays under the hood. This is
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
sturlamolden [EMAIL PROTECTED] writes:
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.
But that's what Lisp
with a cell class like this:
#!/usr/bin/python
import sys
class Cell:
def __init__( self, data, next=None ):
self.data = data
self.next = next
def __str__( self ):
return str( self.data )
def echo( self ):
print self.__str__()
--
Dongsheng Ruan wrote:
with a cell class like this:
#!/usr/bin/python
import sys
class Cell:
def __init__( self, data, next=None ):
self.data = data
self.next = next
def __str__( self ):
return str( self.data )
def echo( self ):
print self.__str__()
If you really
How can I implement a linked list like the implementations in c with
struct-s and arrays (or pointers).
to simbolize the working principe
Gary Herron je napisao/la:
Dongsheng Ruan wrote:
with a cell class like this:
#!/usr/bin/python
import sys
class Cell:
def __init__(
Thanks for your kindly help.
I am new CS student taking datat structure and algorithms with AHO's book
with the same title.
The book is done in Pascal, which might be an outdated language.
However, my instructor probably wants us to understand the list ADT better
by not using the built in list
Gary Herron:
If you really want a list (as Python defines a list - with all the methods)
then you should use Python's lists. They are quite efficient and convenient:
In CPython they are dynamic arrays, they aren't lists. Try adding
elements at the beginning of a list compared to adding
Dongsheng Ruan wrote:
with a cell class like this:
#!/usr/bin/python
import sys
class Cell:
def __init__( self, data, next=None ):
self.data = data
self.next = next
def __str__( self ):
return str( self.data )
def echo( self ):
print self.__str__()
Hi,
The How to
Dongsheng Ruan a écrit :
Thanks for your kindly help.
I am new CS student taking datat structure and algorithms with AHO's book
with the same title.
The book is done in Pascal, which might be an outdated language.
Yes, somehow - but note, that linked lists are the central data
structure
At Tuesday 16/1/2007 17:07, Dongsheng Ruan wrote:
Thanks for your kindly help.
I am new CS student taking datat structure and algorithms with AHO's book
with the same title.
The book is done in Pascal, which might be an outdated language.
However, my instructor probably wants us to understand
Every language has its own way to do the business!
Python has a more abstract data type as the common tools.
Just do things in pythonic way!
On 1月17日, 上午9时55分, Gabriel Genellina
[EMAIL PROTECTED] wrote:
At Tuesday 16/1/2007 17:07, Dongsheng Ruan wrote:
Thanks for your kindly help.
I am new CS
Bruno Desthuilliers wrote:
Implementing linked lists in Python is not a great deal - it just
doesn't make much sens.
It does make sence, as there are memory constraints related to it.
Python lists are arrays under the hood. This is deliberately. Dynamic
arrays grows faster than lists for the
19 matches
Mail list logo