Forum Discussion
Anonymous
4 years agoNot applicable
Merging columns but ignore repeating items across a row
Hi, this is my initial table: Symbols (*) (^) (!) (~) I want to create a list of all the combinations of these 4 symbols. The order of the symbols doesn't matter, its just...
- 4 years ago
It sounds like you want the set of all possible subsets of these four symbols.
If that's correct, you may be interested in my comment on smpa01's combinatorics blog post. In particular, you can generate the list of combinations as follows:
let Source = {"(*)", "(^)", "(!)", "(~)"}, N = List.Count(Source), Subsets = List.Transform( {0..Number.Power(2, N)-1}, (i) => List.Transform( {0..N-1}, (j) => if Number.Mod(Number.IntegerDivide(i, Number.Power(2, j)), 2) = 1 then Source{j} else null ) ), Concatenate = List.Transform(Subsets, each Text.Combine(List.RemoveNulls(_), "")) in ConcatenateOutput:
AlexisOlson
Super User
4 years agoIt sounds like you want the set of all possible subsets of these four symbols.
If that's correct, you may be interested in my comment on smpa01's combinatorics blog post. In particular, you can generate the list of combinations as follows:
let
Source = {"(*)", "(^)", "(!)", "(~)"},
N = List.Count(Source),
Subsets =
List.Transform(
{0..Number.Power(2, N)-1},
(i) => List.Transform(
{0..N-1},
(j) => if Number.Mod(Number.IntegerDivide(i, Number.Power(2, j)), 2) = 1
then Source{j}
else null
)
),
Concatenate = List.Transform(Subsets, each Text.Combine(List.RemoveNulls(_), ""))
in
Concatenate
Output:
- Anonymous3 years agoNot applicable
Excellent! Thank you so very much.