let rec subset l = match l with | [] -> [[]] | (x::xs) -> let second = subset xs in [for y in second -> x::y] @ second let set = [1;2;3;4] subset set |> printfn "%A"
Standard input is empty
[[1; 2; 3; 4]; [1; 2; 3]; [1; 2; 4]; [1; 2]; [1; 3; 4]; [1; 3]; [1; 4]; [1]; [2; 3; 4]; [2; 3]; [2; 4]; [2]; [3; 4]; [3]; [4]; []]