MathTop

powerset 函数

返回列表、集合或整数范围 1..n 的所有子集。

语法

  • powerset(list)
  • powerset(n)
  • power_set(list)
  • combinat:-powerset(list)
  • combinat[powerset](list)

参数与选项

list形如 [1, 2, 3] 的列表字面量。

示例

  1. 幂集powerset([x, y])返回 [[], [x], [y], [x, y]]。
  2. 整数范围幂集powerset(3)返回 [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]。
  3. 包式调用combinat:-powerset([x, y])返回 [[], [x], [y], [x, y]]。