[Haskell-cafe] Permutations

Jake Mcarthur jake at pikewerks.com
Sun Nov 30 11:06:03 EST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Nov 30, 2008, at 9:03 AM, Andrew Coppin wrote:
> OK, so here's something just for fun:
>
> Given a list of items, find all possible *unique* permutations of  
> that list. (E.g., the input list is explicitly _allowed_ to contain  
> duplicates. The output list should not contain any duplicate  
> permutations.)
>
> I've found one simple way to do this, but I'm sure there are  
> multiple valid approaches. So let's see what people come up with. ;-)

Seems a bit easy, I think.

     Data.List.permutations . nub
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (Darwin)

iEYEARECAAYFAkkyuesACgkQye5hVyvIUKn1bQCgwEOBQsDg7L2O6JneaMROZUtw
AXwAnjkUOBFTjkf2G41BBG4++tFjpRzn
=a1z/
-----END PGP SIGNATURE-----


More information about the Haskell-Cafe mailing list