
First line is necessary, because the second line is written in assumption that the first element of a permutation does really exist. On 30 Nov 2008, at 19:49, Andrew Coppin wrote:
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