RosettaCodeData/Task/Power-set/Julia/power-set-1.jl
2024-10-16 18:07:41 -07:00

7 lines
193 B
Julia

function powerset(x::Vector{T})::Vector{Vector{T}} where T
result = Vector{T}[[]]
for elem in x, j in eachindex(result)
push!(result, [result[j] ; elem])
end
result
end