static combinations(set) {
  	var k, i, combs, k_combs;
  	combs = [];

  	// Calculate all non-empty k-combinations
  	for (k = 1; k <= set.length; k++) {
  		k_combs = Combinations.k_combinations(set, k);
  		for (i = 0; i < k_combs.length; i++) {
  			combs.push(k_combs[i]);
  		}
  	}
  	return combs;
  }
Combinations

Get all possible combinations of elements in a set.

Usage:
  combinations(set)

Examples:

  combinations([1, 2, 3])
  -> [[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]

  combinations([1])
  -> [[1]]