inits
Josef Svenningsson
josef.svenningsson at gmail.com
Sat Apr 8 19:08:29 EDT 2006
On 4/8/06, Tim Toorop <timtoorop at quicknet.nl> 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.
Cheers,
/Josef
More information about the Libraries
mailing list