Welcome! Please see the About page for a little more info on how this works.

+2 votes
in Clojure by

Bring external interface of map-indexed in line with map. Existing usages of map-indexed unchanged both in implementation and interface.

(map vector (range 10 20) (range 30 35)) ;=> ([10 30] [11 31] [12 32] [13 33] [14 34]) (map-indexed vector (range 10 20) (range 30 35)) ;=> ([0 10 30] [1 11 31] [2 12 32] [3 13 33] [4 14 34])

Patch: CLJ-1601 map-indexed and tests 8-5-2017.patch - also adds tests for map-indexed

Prescreened by: Alex Miller

13 Answers

0 votes
by

Comment made by: aaron

Can you add a test for the improved functionality?

0 votes
by

Comment made by: bjeanes

You bet. I tried to before submitting this but found no existing tests for map-indexed to expand upon. Given that, I decided to just start the conversation first. If you think this is a good addition, I'll find a place to stick the tests and add a new patch file.

0 votes
by

Comment made by: bjeanes

Add two unit tests for {{map-indexed}}. One tests old behavior (single collection) and the second tests mapping across 3 collections.

There were no existing tests for {{map-indexed}} that I could see to expand upon (using {{git grep map-indexed src/clojure}})

0 votes
by

Comment made by: justinspedding

This feature would be very useful. Is there a reason that no one continued to work on this in almost 5 years?

0 votes
by

Comment made by: alexmiller

Predates my involvement with Clojure so don't know but don't see any reason why not.

0 votes
by

Comment made by: jafingerhut

If a ticket has not been moved to the Vetted state by Rich Hickey, it is unknown whether it is of interest to be added to Clojure at all. The default answer to any change to Clojure, until there is a compelling argument to the core Clojure developers otherwise, is "no". That said, JIRA tickets tend to be left open rather than declined if there is no compelling argument for declining it.

For some more background, see here, in particular the "Clojure Governance and How It Got That Way" article linked from there: https://dev.clojure.org/display/community/Contributing FAQ

For details on Vetted, and other JIRA ticket statuses used by the Clojure core team, see here: https://dev.clojure.org/display/community/JIRA workflow

Voting on tickets (there is a "Vote" link near the top right of the page if you log in to your JIRA account first) can in some cases help get attention to them sooner than tickets without votes, but there are no guarantees on time lines.

0 votes
by

Comment made by: alexmiller

I didn't try but I'm sure this patch no longer applies. Having a single combined patch that can be applied would be a useful first step.

0 votes
by

Comment made by: justinspedding

I just uploaded a new patch for map-indexed that allows it to accept multiple collections. I took the exact same approach that map does, but with the addition of the index. It has better performance than the old patch from 2012. I also included more tests. Both the function update and the new tests are in "CLJ-1601 map-indexed and tests 8-5-2017.patch"

Also, map-indexed had 0 tests prior to me writing the patch. That seems a bit dangerous for a function in core to be untested.

0 votes
by

Comment made by: justinspedding

It's been a little while since I uploaded the patch here and it was prescreened. Both this ticket and another that I created are awaiting vetting, and the FAQ says that I should tend to my tickets. Is there something else that I should be doing to tend to it and move it along?

0 votes
by

Comment made by: alexmiller

I don't think we'll consider any more enhancements in 1.9 timeframe.

0 votes
by

Comment made by: justinspedding

It occurs to me that keep and keep-indexed also do not accept multiple collections. Perhaps I should make a similar ticket for updating those.

0 votes
by
_Comment made by: alexmiller_

Yes, separate ticket for those would be good. I don’t know of one in existence yet.
0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1095 (reported by bjeanes)
...