I am new to Sage and trying to define a recursive function that returns the subsets for a given set. I get some sort of memory error for even the smallest sets and I don't know why:
def MySubsets(L): if L == []: return [[]]
TheSubsets = MySubsets(L[1:len(L)])
for subset in TheSubsets:
newSubset = copy(subset)
newSubset.append(L[0])
TheSubsets.append(newSubset)
return TheSubsets
...and while MySubsets([]) works, MySubsets([1]) already yields a memory error.