IterTools.jl icon indicating copy to clipboard operation
IterTools.jl copied to clipboard

Differences in `Base.Iterators.map` and `IterTools.imap`

Open PatrickHaecker opened this issue 10 months ago • 3 comments

We should document the difference between Base.Iterators.map and IterTools.imap or document that there is no difference.

I think that there is no difference, but I am not certain that

map(f, arg, args...) = Base.Generator(f, arg, args...)

and

imap(mapfunc, it1, its...) = (mapfunc(xs...) for xs in zip(it1, its...))

always will behave identical. Both create a Base.Generator and I think the zip does not change here anything as Generator is also using zip:

Generator(f, I1, I2, Is...) = Generator(a->f(a...), zip(I1, I2, Is...))

Can someone confirm, that they are identical, so that we can create a PR to document it?

PatrickHaecker avatar Feb 16 '25 06:02 PatrickHaecker

They are identical and we should delete ours. it is just that this is older than that being in Base.Iterators

oxinabox avatar Feb 17 '25 09:02 oxinabox

Would you prefer doing this yourself or getting a PR? I am hesitant, as this PR would imply a SemVer version update. Would this update be included in the PR? I can't promise that I'll find the time, but it probably does not hurt to document the preferred way.

PatrickHaecker avatar Feb 17 '25 10:02 PatrickHaecker

I was going to suggest adding Iterators.map to Compat.jl but Iterators.map has existed since Julia 1.6 so it doesn't seem worth it

omus avatar Feb 18 '25 19:02 omus