WolframLang: List Combinatorics
Tuples
-
Tuples[ list, n]
- and more
return all possible n-tuples.
Tuples[ {1,2,3}, 2] === {{1, 1}, {1, 2}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 1}, {3, 2}, {3, 3}}
Subsets
-
Subsets[list]
→ all subsets.Subsets[list, n]
→ max subset length n.Subsets[list, {n}]
→ subset length exactly n.Subsets[list, {n, m}]
→ subset length n to m.Subsets[list, spec, s]
→ first s subsets.
return all possible subsets
xx = {1,2,3}; Subsets[xx] === {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}} (* max length n in each subset. *) Subsets[xx, 2] === {{}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}} (* exact length n in each subset. *) Subsets[xx, {2}] === {{1, 2}, {1, 3}, {2, 3}} (* length n to m in each subset. *) Subsets[xx, {2,3}] === {{1, 2}, {1, 3}, {2, 3}, {1, 2, 3}} (* just first 4 subsets. *) Subsets[xx, 2, 5] === {{}, {1}, {2}, {3}, {1, 2}}
Permutations
WolframLang List Operations
- WolframLang: List Operations
- WolframLang: Get Parts of List
- WolframLang: Add Element to List
- WolframLang: Delete Element in List
- WolframLang: Change Element in List
- WolframLang: Check Item Exist in List
- WolframLang: Filter List
- WolframLang: Sort, Reverse, Order
- WolframLang: List Reshape (split, group, flatten, transpose)
- WolframLang: List Combinatorics
- WolframLang: List Join, Union, Intersection, Difference