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

9 lines
192 B
Text
Raw Permalink Normal View History

2013-04-10 22:43:41 -07:00
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];;