RosettaCodeData/Task/Power-set/OCaml/power-set-2.ml

2 lines
96 B
OCaml

let subsets xs = List.fold_right (fun x rest -> rest @ List.map (fun ys -> x::ys) rest) xs [[]]