How would you call a function that returns all pos...
# stdlib
m
How would you call a function that returns all possible sublists of a list? e.g. for
listOf(A, B)
=>
listOf(emptyList(), listOf(A), listOf(B), listOf(A, B))
v
It is "permutations" or "combinations", and traditionally they are used on indices, then applied to a list with `list.slice(perm)
See how it is done in python
m
Permutation means arranging all elements, like
listOf(B, A), listOf(A, B))
Combination is a bit closer, but I always think of it as selecting k elements from n-set, like lotto. Maybe this term can be used more broadly to name all k-combinations, where k is 0 to set size.
v
or, I see
you wanted sublists of all lengths
sorry I didn't read it right
in math it is called "2^N". It is used as an operator similar to C_n^k
m
Um…
allSublistsOf(List)
? 🙃
🤔 1
m
2^S
is only a notation in a case where S set is finite set, because |P(S)| = 2^n 🙂 actually, in math, it's called
power set
> #random
💡 1
m
@masted Thanks. I never heard of
power set
, but this is exactly what it is.
👍 1