From d721f387aaa90ad08423880ef02c5f74fccbec2c Mon Sep 17 00:00:00 2001 From: Casey Dahlin Date: Tue, 23 Dec 2008 00:14:11 -0500 Subject: New function to find the cross product of two sets --- setcross.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 setcross.py 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 -- cgit