view julia/recursion.jl @ 6:661876a2502e

py: dp
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 19 Feb 2023 12:50:44 +0100
parents c1db337c15be
children
line wrap: on
line source


function combinations(n::Int, k::Int)::Vector
    if k == 1
        return collect(1:n)
    end
    lower = combinations(n, k-1)
    [(i, l...) for i in 1:n for l in lower]
end