Add 'subsequences' and 'permutations' to Data.List (ticket #1990)

David Benbennick dbenbenn at
Tue Dec 18 21:52:06 EST 2007

On Dec 18, 2007 6:25 PM, Twan van Laarhoven <twanvl at> wrote:
> David Benbennick wrote:
> > The same issue applies to permutations.  I haven't had time to write
> > out the code yet, but I can imagine a version of permutations that
> > does:  ...
> Using mutual recursion between a version including the identity and one
> not including it, you can get:

Actually, I would like permutations to satisfy:

  map (take n) (take (factorial n) $ permutations [1..]) == permutations [1..n]

Not only is that a neat property, but it forces maximal laziness.
That means, for example, that:

  take 6 $ map (take 3) $ permutations (1:2:3:undefined)

doesn't throw an exception.

More information about the Libraries mailing list