Guest User

Untitled

a guest
Jun 13th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.28 KB | None | 0 0
  1. (* recursively generate all the permutations of a list *)
  2. let rec perms L =
  3.   if L <> [] then
  4.     let nextPerm e =
  5.       let tl = List.filter (fun x -> x <> e) L
  6.       List.map (fun perm -> e::perm) (perms tl)  
  7.     List.concat <| List.map (nextPerm) L
  8.   else [[]]
  9.  
  10. perms [1;2;3;4]
Add Comment
Please, Sign In to add comment