RosettaCodeData/Task/Combinations/OCaml/combinations-1.ocaml

9 lines
192 B
Plaintext

let rec comb m lst =
match m, lst with
0, _ -> [[]]
| _, [] -> []
| m, x :: xs -> List.map (fun y -> x :: y) (comb (pred m) xs) @
comb m xs
;;
comb 3 [0;1;2;3;4];;