diff options
author | Casey Dahlin <cdahlin@redhat.com> | 2008-12-23 00:14:11 -0500 |
---|---|---|
committer | Casey Dahlin <cdahlin@redhat.com> | 2008-12-23 00:14:11 -0500 |
commit | d721f387aaa90ad08423880ef02c5f74fccbec2c (patch) | |
tree | 99ec481cd8ecb698e0defbb6bfeaaceb7a2c9ddf | |
parent | 26df5dded6963cee63b2a966bd7e654b35a0d4ce (diff) | |
download | upstate-d721f387aaa90ad08423880ef02c5f74fccbec2c.tar.gz upstate-d721f387aaa90ad08423880ef02c5f74fccbec2c.tar.xz upstate-d721f387aaa90ad08423880ef02c5f74fccbec2c.zip |
New function to find the cross product of two sets
-rw-r--r-- | setcross.py | 12 |
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 |