Power set: Difference between revisions
→Non-Mutating Solution
Line 2,223:
using Base.Iterators
function bitmask(u, max_size)
function powerset(x::Vector{T})::Vector{Vector{T}} where T ▼
res = BitArray(undef, max_size)
bitstring_map(x) = Iterators.map(bitstring, x)▼
res.chunks[1] = u%UInt64
reverse_map(x) = Iterators.map(reverse, x)▼
res
end
num_elements = length(input_collection)
bitstring_map |>▼
reverse_map▼
UnitRange(0, (2^num_elements)-1) |>
getindex_map |>
end
</syntaxhighlight>
|