Re: unique elements from list of lists

2007-02-10 Thread azrael
no heart feelings. i was just throwing ideas. no time to testing it. On Feb 9, 3:55 pm, "Tekkaman" <[EMAIL PROTECTED]> wrote: > Thanks everybody!Azrael: your suggestions involve python-level membership > testing and > dummy list construction just like my uniter3 example, so I'm afraid > they wou

Re: unique elements from list of lists

2007-02-09 Thread Tekkaman
Thanks everybody! Azrael: your suggestions involve python-level membership testing and dummy list construction just like my uniter3 example, so I'm afraid they would not go any faster. There's no built-in sequence flattening function that I know of btw. bearophile: your implementation is very simil

Re: unique elements from list of lists

2007-02-09 Thread bearophileHUGS
Tekkaman: If the sublists contain hashable elements you can use this: def uniter(lists): merge = set() for sub in lists: merge = merge.union(sub) for el in merge: yield el data = [['a', 'b', 'd'], ['b', 'c'], ['a', 'c', 'd']] print list(uniter(data)) But often this t

Re: unique elements from list of lists

2007-02-09 Thread azrael
tra using the firs sublist (list[1]) as cell.then take zhe second sublist and take a value from it at once and if the value from list[2] doesnt exist in list[1] then insert it into list[1] at the correct place. Something like the insertionsort. -- http://mail.python.org/mailman/listinfo/python-li

Re: unique elements from list of lists

2007-02-09 Thread azrael
try something else. im posting the code from a kiosk which has no python, sooo. no code. only explanation if my memory works well there is a function in python that takes a multidimensional list and returns its values as a one-dimension list. def main(): list =unknownFunction([['a', 'b', '

Re: unique elements from list of lists

2007-02-09 Thread Peter Otten
Tekkaman wrote: > I have a list of lists and I want to define an iterator (let's call > that uniter) over all unique elements, in any order. For example, > calling: > > sorted(uniter([['a', 'b', 'd'], ['b', 'c'], ['a', 'c', 'd']])) > > must return ['a', 'b', 'c', 'd']. I tried the following > im

unique elements from list of lists

2007-02-09 Thread Tekkaman
I have a list of lists and I want to define an iterator (let's call that uniter) over all unique elements, in any order. For example, calling: sorted(uniter([['a', 'b', 'd'], ['b', 'c'], ['a', 'c', 'd']])) must return ['a', 'b', 'c', 'd']. I tried the following implementations: from itertools im