Reputation: 33385
The F# findIndex
function finds the index of the first list element that satisfies a certain predicate.
I want to write a similar function except where the predicate takes a list instead of a single element. So if the predicate looks for a list beginning with 1 followed by 0, then given [0; 1; 1; 0]
the function would return 2. (The actual current use case I have in mind is searching a list of characters for a closing quote, but being able to skip quotes that are escaped with \
.)
The function should be reasonably straightforward to write. My question is, what should it be named? The standard library doesn't seem to contain any examples of 'take a list instead of a single element' so I don't know what the idiomatic naming scheme for that would be.
Upvotes: 2
Views: 186
Reputation: 571
You are searching for an index and findIndex is already taken. findIndex returns an item index and could arguably be named findItemIndex. Following that line of thought, you could go with findItemsIndex because you are searching the index of a list of items in the list.
Upvotes: 1