Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. perms [] = [[]]
  2.     perms (x:xs) = concat.(map $ \list -> inject x list) $ perms xs
  3.         where
  4.             inject x list = map (\p -> (take p list) ++ [x] ++ (drop p list)) [0..last]
  5.                 where
  6.                     last = length list
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement