|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /proc/self/root/usr/lib/python2.4/site-packages/_xmlplus/xpath/ |
Upload File : |
########################################################################
#
# File Name: Set.py
#
#
"""
WWW: http://4suite.org/ e-mail: support@4suite.org
Copyright (c) 2000-2001 Fourthought Inc, USA. All Rights Reserved.
See http://4suite.org/COPYRIGHT for license and copyright information
"""
def Not(original,other):
return filter(lambda x,other=other:x not in other,original)
def Union(left,right):
if len(left) < len(right):
loop = left
compare = right
else:
loop = right
compare = left
return compare + filter(lambda x,compare = compare:x not in compare,loop)
def Intersection(left,right):
if len(left) < len(right):
loop = left
compare = right
else:
loop = right
compare = left
return filter(lambda x,compare = compare:x in compare,loop)
def Unique(left):
return reduce(lambda rt,x:x in rt and rt or rt + [x],left,[])