Clojure

Allow map-indexed to accept multiple collections (a la map)

Details

  • Type: Feature Feature
  • Status: Open Open
  • Priority: Trivial Trivial
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Approval:
    Prescreened

Description

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

examples
(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

Activity

Hide
Aaron Bedra added a comment -

Can you add a test for the improved functionality?

Show
Aaron Bedra added a comment - Can you add a test for the improved functionality?
Hide
Bo Jeanes added a comment -

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.

Show
Bo Jeanes added a comment - 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.
Hide
Bo Jeanes added a comment -

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)

Show
Bo Jeanes added a comment - 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)
Hide
Justin Spedding added a comment - - edited

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

Show
Justin Spedding added a comment - - edited This feature would be very useful. Is there a reason that no one continued to work on this in almost 5 years?
Hide
Alex Miller added a comment -

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

Show
Alex Miller added a comment - Predates my involvement with Clojure so don't know but don't see any reason why not.
Hide
Andy Fingerhut added a comment - - edited

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.

Show
Andy Fingerhut added a comment - - edited 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.
Hide
Alex Miller added a comment -

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.

Show
Alex Miller added a comment - 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.
Hide
Justin Spedding added a comment -

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.

Show
Justin Spedding added a comment - 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.
Hide
Justin Spedding added a comment -

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?

Show
Justin Spedding added a comment - 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?
Hide
Alex Miller added a comment -

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

Show
Alex Miller added a comment - I don't think we'll consider any more enhancements in 1.9 timeframe.

People

Vote (2)
Watch (3)

Dates

  • Created:
    Updated: