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

Bo Jeanes made changes -
Field Original Value New Value
Attachment 0002-Add-test-for-multi-collection-map-indexed-fn.patch [ 11616 ]
Andy Fingerhut made changes -
Patch Code and Test [ 10002 ]
Alex Miller made changes -
Issue Type Enhancement [ 4 ] Feature [ 5 ]
Alex Miller made changes -
Issue Type Feature [ 5 ] Enhancement [ 4 ]
Justin Spedding made changes -
Justin Spedding made changes -
Comment [ updated patch ]
Alex Miller made changes -
Approval Triaged [ 10120 ]
Description Bring external interface of map-indexed in line with map. Existing usages of map-indexed unchanged both in implementation and interface.

{code:title=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])
{code}

The attached patch is not necessarily the best implementation (I haven't benchmarked it or tried any alternatives yet) but hopefully enough to start a conversation about whether this is an addition that is warranted. I know I wished for this behavior a few weeks ago though I ended up finding another way.

(I haven't sent my CA yet, but I have it signed and ready to send in the next few days)
Bring external interface of map-indexed in line with map. Existing usages of map-indexed unchanged both in implementation and interface.

{code:title=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])
{code}

*Patch:* CLJ-1601 map-indexed and tests 8-5-2017.patch - also adds tests for map-indexed
Alex Miller made changes -
Approval Triaged [ 10120 ] Prescreened [ 10220 ]
Description Bring external interface of map-indexed in line with map. Existing usages of map-indexed unchanged both in implementation and interface.

{code:title=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])
{code}

*Patch:* CLJ-1601 map-indexed and tests 8-5-2017.patch - also adds tests for map-indexed
Bring external interface of map-indexed in line with map. Existing usages of map-indexed unchanged both in implementation and interface.

{code:title=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])
{code}

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

*Prescreened by:* Alex Miller
Alex Miller made changes -
Issue Type Enhancement [ 4 ] Feature [ 5 ]

People

Vote (1)
Watch (3)

Dates

  • Created:
    Updated: