Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* recursively generate all the permutations of a list *)
- let rec perms L =
- if L <> [] then
- let nextPerm e =
- let tl = List.filter (fun x -> x <> e) L
- List.map (fun perm -> e::perm) (perms tl)
- List.concat <| List.map (nextPerm) L
- else [[]]
- perms [1;2;3;4]
Add Comment
Please, Sign In to add comment