[plt-scheme] should `map' reuse cons cells?

From: Doug Orleans (dougo at place.org)
Date: Wed May 26 17:08:31 EDT 2004

Eli Barzilay writes:
 > On May 26, Doug Orleans wrote:
 > > Anyway, I think it would be nice for PLT's implementation of `map' to
 > > reuse longest common tails.  (Or at least PLT's implementation of
 > > SRFI-1's version of `map'.)  Thoughts?
 > Wouldn't it be healthier to simply add a `map!'?

SRFI-1 has a `map!', but that's something different: it doesn't just
reuse cons cells from its input, it mutates them.  I want a functional
`map', but one that doesn't create new cells for sublists if all the
elements are `eq?' to the original.  Besides minimizing garbage, it
would speed up things like `equal?' later on (assuming it uses `eq?'
to shortcut).

--dougo at place.org

Posted on the users mailing list.