Created
October 19, 2009 21:15
-
-
Save abuiles/213716 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
perm :: [Int] -> [ [Int]] | |
perm [] = return [] | |
perm (x:xs) = do ys <- perm xs | |
zs <- insert x ys | |
return zs | |
insert :: a -> [a] -> [[a]] | |
insert x xs = (return (x:xs)) | |
`mplus` case xs of | |
[] -> mzero | |
(y:ys) -> liftM (y:) (insert x ys) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment