Power set: Difference between revisions
Content added Content deleted
m (→{{header|MATLAB}}: Fixed a typo and changed a variable name so it doesn't conflict with any MATLAB keywords) |
m (→{{header|MATLAB}}: Messed up the powerset preallocation, fixed it.) |
||
Line 785: | Line 785: | ||
<lang MATLAB>function pset = powerset(theSet) |
<lang MATLAB>function pset = powerset(theSet) |
||
pset = |
pset = cell(size(theSet)); %Preallocate memory |
||
%Generate all numbers from 0 to 2^(num elements of the set)-1 |
%Generate all numbers from 0 to 2^(num elements of the set)-1 |