summaryrefslogtreecommitdiffstats
path: root/setcross.py
blob: fa1b865bc5a52c8f09acb7780fb7842191854413 (plain)
1
2
3
4
5
6
7
8
9
10
11
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