list_multichoose 函数
返回允许重复使用位置的 k 元选择。
语法
list_multichoose(list, k)combinations_with_replacement(list, k)
参数与选项
list | 形如 [1, 2, 3] 的列表字面量。 |
|---|---|
k | 选取的元素数量。 |
示例
- 可重复列表选择
list_multichoose([x, y], 3)返回 [[x, x, x], [x, x, y], [x, y, y], [y, y, y]]。
返回允许重复使用位置的 k 元选择。
list_multichoose(list, k)combinations_with_replacement(list, k)list | 形如 [1, 2, 3] 的列表字面量。 |
|---|---|
k | 选取的元素数量。 |
list_multichoose([x, y], 3)返回 [[x, x, x], [x, x, y], [x, y, y], [y, y, y]]。