function _subset(array, bitarray) {
    var result = [];

    for (var i = 0; i < bitarray.length; i++) {
      if (bitarray[i] === '1') {
        result.push(array[i]);
      }
    }

    return result;
  } // sort subsests by length
Create the powerset of a (multi)set. (The powerset contains very possible subsets of a (multi)set.)
A multi-dimension array will be converted to a single-dimension array before the operation.

Syntax:

   math.setPowerset(set)

Examples:

   math.setPowerset([1, 2, 3])        // returns [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]

See also:

   setCartesian

@param {Array | Matrix}    a  A (multi)set
@return {Array}    The powerset of the (multi)set