Oops,
For listing all different subsets of a list (This is what I came up
with. Can it be implemented shorter, btw?):
def subsets(L):
S = []
if (len(L) == 1):
return [L, []]
better to check for the empty set too, thus;
if (len(L) == 0):
return [[]]
The order of the sets looks better too;
>>> subset.subsets([1,2,3])
[[], [1], [2], [2, 1], [3], [3, 1], [3, 2], [3, 2, 1]]
cheers,
--
http://mail.python.org/mailman/listinfo/python-list
