-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access the index on map() operations #88
Comments
I've played around with a naive implementation:
Maybe one could use the depth and branchingFactor instead but this seems performance-wise to already fare better than zipWith. Here are my rudimentary benchmark results:
|
@Mistyputt I just ran into the same issue where I want to know which position in a row an element was clicked. The row is created using map function.
I guess a workaround for now can be to use |
Thanks for opening the issue and providing feedback. I definitely agree that it would be nice to offer an easy way to map with an index. I think your |
Absolutely! I did work around a few issues building the project when trying out that implementation and would feel better if I had a "clean" project when submitting the PR. After cloning I ran
As no one else has reported this I feel I'm missing something obvious. When I played around with the mapWithIndex implementation I just commented out I built with node v10.19.0. Any pointers? |
Hi
My use case frequently involves mapping a list of raw data into a UI representation that offers the ability to modify elements. For instance mapping a list into table rows, where the user may modify or delete rows. I was thinking having the index available when mapping would allow me to efficiently update the list on that index.
One could use List.zipWith(f, list, List.range(0,List.length(list))) or avoid the index and use List.find but maybe there is a place for a dedicated mapWithIndex function as that should theoretically be more efficient?
Does anyone else have similar use-cases and what is your solution?
Finally, thanks for a great lib!
The text was updated successfully, but these errors were encountered: