delete duplicates in list
Dave Benjamin
ramen at lackingtalent.com
Mon Nov 3 00:21:21 EST 2003
In article <mailman.285.1067612751.702.python-list at python.org>, Martin Chilvers wrote:
> Maybe I'm just old-school, and it won't win any prizes for speed but...
>
>>>> a = [1, 3, 2, 3, 4, 2, 1, 4, 3, 2, 1, 2, 4]
>>>> reduce(lambda l, x: x not in l and l.append(x) or l, a, [])
> [1, 3, 2, 4]
>
> ;^)
Hey, I wanna play this game too:
[d.setdefault(x, x) for d in [{}] for x in a if x not in d]
Now, try replacing that with "old-school" functionals. I'm stumped. =)
--
.:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:.
: d r i n k i n g l i f e o u t o f t h e c o n t a i n e r :
More information about the Python-list
mailing list