I'm trying to write a function that will take an array on input and return array of arrays, containing all possible subsets of input array (power set without empty element). For example for input: [1, 2, 3]
the result would be [[1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]
.
This function does the job in python:
def list_powerset(lst):
result = [[]]
for x in lst:
result += [subset + [x] for subset in result]
result.pop(0)
return result
But I'm looking for implementation of it in Delphi. Is this possible to accomplish this way or should I look for something else?