diff options
Diffstat (limited to 'setcross.py')
-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 |