[sage-support] Re: Finding a duplicated vector in a list of vectors

2009-01-20 Thread Carl Witty
On Jan 19, 1:43 pm, slabbe wrote: > PROBLEM : > In a list of vectors, I want to know if there is a pair of equal > vectors. > > I have two solutions. The first to create an empty list L and append > the vectors one per one. If a vector is already in L before adding it, > then I found a pair of eq

[sage-support] Re: Finding a duplicated vector in a list of vectors

2009-01-19 Thread David Joyner
You're right. This is what I meant: sage: L = [vector([1,0,0]), vector([1,2,0]), vector([1,0,3]), vector([1,0,0])] sage: LL = [tuple(v.list()) for v in L] sage: Set(LL) {(1, 0, 0), (1, 0, 3), (1, 2, 0)} But that is probably what you said in the first place. Here's another idea: sage: L = [vect

[sage-support] Re: Finding a duplicated vector in a list of vectors

2009-01-19 Thread slabbe
> I don't know if this is the best idea or not but I definitely have > run into this problem before and what I think I did was > to store the list of vectors as a *Set* of *lists*. Are you sure? Because as vectors, lists are unhashable : ... TypeError: list objects are unhashable --~--~-

[sage-support] Re: Finding a duplicated vector in a list of vectors

2009-01-19 Thread David Joyner
I don't know if this is the best idea or not but I definitely have run into this problem before and what I think I did was to store the list of vectors as a *Set* of *lists*. On Mon, Jan 19, 2009 at 4:43 PM, slabbe wrote: > > PROBLEM : > In a list of vectors, I want to know if there is a pair of