
18 Dec
2007
18 Dec
'07
9:52 p.m.
On Dec 18, 2007 6:25 PM, Twan van Laarhoven
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.