Miguel Mitrofanov wrote:
eqPerms [] = [[]]
eqPerms xs = [x:xt | x <- nub xs, xt <- eqPerms $ delete x xs]
Well, that's one way... ;-)
I'm still not precisely sure why the first line must exist, but it seems
no matter which way round you do it, that line is needed. Probably due
to some subtlety of the list monad...
I'm not sure how efficient using the delete function is, but this
version definitely has the virtues of brevity and readbility.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe