batteries icon indicating copy to clipboard operation
batteries copied to clipboard

Return index with functional's "find" functions

Open fingoltin opened this issue 4 years ago • 1 comments

It would be nice if the find family of functions also gave the index into the table.

fingoltin avatar Sep 15 '21 03:09 fingoltin

Sorry for missing this for so long!

We could, but I'm actually looking at going the other way in terms of the functional api, and removing the often-superfluous index values and providing a _with_index version of functions that changed (eg map and map_with_index) - find_match_with_index could work too, or just find_match_index that just returns the index.

At present - unless you're on a very big collection - the likely anonymous function declaration each time find is used will be more expensive than the O(N) search for table.index_of to get the index.

1bardesign avatar Nov 17 '21 23:11 1bardesign