Josef Svenningsson josef.svenningsson at
Sat Apr 8 19:08:29 EDT 2006

On 4/8/06, Tim Toorop <timtoorop at> wrote:
> On the other hand, I think the new spiffy inits is quite clear once you
> notice why its  map (const xn) $ undefined:xn

I think it would be even clearer if it were defined like this:

> inits xs = zipWith take [0..] $ map (const xs) xs

That way you don't have this ugly special case for the first element
in the list. But there is an even better advantage: it is strict
again! So it's termination properties are exactly like the Prelude
one. This version *can* be used as a drop-in replacement of the
Prelude version.



More information about the Libraries mailing list