summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCasey Dahlin <cdahlin@redhat.com>2008-12-23 00:14:11 -0500
committerCasey Dahlin <cdahlin@redhat.com>2008-12-23 00:14:11 -0500
commitd721f387aaa90ad08423880ef02c5f74fccbec2c (patch)
tree99ec481cd8ecb698e0defbb6bfeaaceb7a2c9ddf
parent26df5dded6963cee63b2a966bd7e654b35a0d4ce (diff)
downloadupstate-d721f387aaa90ad08423880ef02c5f74fccbec2c.tar.gz
upstate-d721f387aaa90ad08423880ef02c5f74fccbec2c.tar.xz
upstate-d721f387aaa90ad08423880ef02c5f74fccbec2c.zip
New function to find the cross product of two sets
-rw-r--r--setcross.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/setcross.py b/setcross.py
new file mode 100644
index 0000000..fa1b865
--- /dev/null
+++ b/setcross.py
@@ -0,0 +1,12 @@
+def cross(first, *args):
+ """
+ find cross product of two sets.
+ """
+ retval = set([ (x,) for x in first ])
+ for arg in args:
+ next = set()
+ for a in retval:
+ for b in arg:
+ next.add(a + (b,))
+ retval = next
+ return retval