[sage-support] Re: Python lists and removals

2009-10-27 Thread Dag Sverre Seljebotn
Robert Bradshaw wrote: > On Oct 27, 2009, at 3:15 AM, Francois Maltey wrote: > > >> Hello, >> >> I'm an old lisp-list user and python is my first use of dynamic >> array-list. >> >> Complexity for lisp-list is constant and fast o(1) when we add a new >> element at the head of the list. >> (co

[sage-support] Re: Python lists and removals

2009-10-27 Thread Robert Bradshaw
On Oct 27, 2009, at 3:15 AM, Francois Maltey wrote: > Hello, > > I'm an old lisp-list user and python is my first use of dynamic > array-list. > > Complexity for lisp-list is constant and fast o(1) when we add a new > element at the head of the list. > (cons e L) in Lisp or e::L in caml. > > Co

[sage-support] Re: Python lists and removals

2009-10-27 Thread Francois Maltey
Hello, I'm an old lisp-list user and python is my first use of dynamic array-list. Complexity for lisp-list is constant and fast o(1) when we add a new element at the head of the list. (cons e L) in Lisp or e::L in caml. Complexity is also o(1) when we take the end of the list, or read the fi

[sage-support] Re: Python lists and removals

2009-10-26 Thread kcrisman
Great, thanks to both of you. No wonder I didn't see it in the documentation for lists! Luckily my lists are probably very short (len<5) so don't have to worry about algorithms for now, just a bugfix. - kcrisman On Oct 26, 5:02 pm, Jason Grout wrote: > Dag Sverre Seljebotn wrote: > > > a) for

[sage-support] Re: Python lists and removals

2009-10-26 Thread Jason Grout
Dag Sverre Seljebotn wrote: > > a) for x in L[:]: ... # makes a copy > b) remove from the end of the list... c) use list comprehensions to construct a new list, then del the old list. Jason --~--~-~--~~~---~--~~ To post to this group, send email to sage-suppo

[sage-support] Re: Python lists and removals

2009-10-26 Thread Dag Sverre Seljebotn
kcrisman wrote: > Dear support, > > I'm trying to resolve #7315 and have discovered something that > disturbs me, but probably is reasonable to someone who really > understands Python lists. Namely: > > {{{ L=[1,2,3,4] for x in L: > ... L.remove(x) > ... x > ... L > ... >

[sage-support] Re: Python lists and removals

2009-10-26 Thread Jason Grout
kcrisman wrote: > Dear support, > > I'm trying to resolve #7315 and have discovered something that > disturbs me, but probably is reasonable to someone who really > understands Python lists. Namely: > > {{{ L=[1,2,3,4] for x in L: > L.remove(x) > x > L > ...