Tuples
The k-tuples over : all ordered selections with repetition.
✓ checked against that system · ! checked, with disagreements (hover a chip)Wikipedia
TupleMathWorldn-TupleWikidataQ600590OEISA079901✓Wolfram LanguageTuples✓Tuples(n, k)the length- tuplesTuples(list, k)the length- tuples of the list's own elements, as a (up to a size cap)Typed signatures
| Type | Package | Applies |
|---|---|---|
((integer<0..>, integer<0..>) -> indexed_collection<list<integer>>) & ((list<any>, integer<0..>) -> list<list<any>>) | combinatorics | always |
Details
- Count is
- Elements are ordered as mixed-radix (base ) counting
Definition
Epsil, as the implementation runs it.
count(_n, _k)
1 if _k == 0 else _n ^ _kunrank(_n, _k, _r)
Map(
Function((_r - _r % _n ^ (_k - j)) / _n ^ (_k - j) % _n + 1, j),
Range(1, _k, 1),
)rank(_n, _k, _x)
Fold(Function(acc * _n + (_x[j] - 1), acc, j), 0, Range(1, _k, 1))valid(_n, _k, _x)
Length(_x) == _k && Fold(Function(
ok_j && 1 <= _x[j] && _x[j] <= _n + 1 - 1,
ok_j,
j,
), True, Range(1, Length(_x), 1))Examples
About
| Examples | 3 |
|---|---|
| Checked against | Wolfram Language 3 agree |
| Crosswalk | WikipediaMathWorldWikidataOEISWolfram Language |