[Haskell-cafe] Permutations

Andrew Coppin andrewcoppin at btinternet.com
Sun Nov 30 15:27:02 EST 2008


Jake Mcarthur wrote:
> Heh, after a couple more seconds of thought, reversing the two 
> composed functions fixes it:
>
>     nub . permutations
>
> Of course, neither my previous nonsolution nor this solution are 
> efficient for long lists, but I think it serves as a decent reference 
> implementation at least.

Consider the following list:

  [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]

Somebody just pointed out to me that this list has 87,178,291,200 
permutations, of which 14 are unique. O_O



More information about the Haskell-Cafe mailing list