Problem 26 Solution

combinations : Int -> List a -> List (List a)
combinations n list =
    if n <= 0 then
        [ [] ]
    else
        case list of
            [] ->
                []

            x :: xs ->
                List.map ((::) x) (combinations (n - 1) xs) ++ combinations n xs

Back to problem

results matching ""

    No results matching ""