fork download
  1. let rec subset l =
  2. match l with
  3. | [] -> [[]]
  4. | (x::xs) -> let second = subset xs in [for y in second -> x::y] @ second
  5.  
  6. let set = [1;2;3;4]
  7.  
  8. subset set |> printfn "%A"
Success #stdin #stdout 0.2s 26528KB
stdin
Standard input is empty
stdout
[[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]; []]