Map with index.
See original GitHub issuePlease add
map(Func2<? super T, int index, ? extends R> func)
Where the second parameter of Func2
is the index of the element.
A similar overload could be useful on operators like scan
, reduce
, filter
etc.
Issue Analytics
- State:
- Created 8 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Array.prototype.map() - JavaScript - MDN Web Docs
The map() method creates a new array populated with the results of calling a provided function on every element in the calling array....
Read more >Index inside map() function - javascript - Stack Overflow
The index of the current element being processed in the array. 3) array. The array map was called upon. Share.
Read more >Index inside map() Function - GeeksforGeeks
The index is used inside map() method to state the position of each element in an array, but it doesn't change the original...
Read more >JavaScript map index: The Complete Guide - AppDividend
To find an index of the current iterable inside the JavaScript map() function, use the callback function's second parameter. An index used ...
Read more >How to Use Map Index in JavaScript - Linux Hint
In JavaScript, the map index is considered useful in locating the exact position of an array value, especially in the case of complex...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
By the way, mapWithIndex can be implemented by
zipWith(Observable.range(0, Integer.MAX_VALUE))
.Why not use rxjava-extras? 😃
RxJava already has ~4k methods, and it has
compose()
and some other ways to be extendable.I’d say, that existing operators are enough to do what you want, though, it’s a little bit less effective than native operator because it creates new Pair each time:
// I have nothing personal against indexed operators, but at the same time I’d vote for keeping API “small”.