ogma
ogma copied to clipboard
[FEATURE] `idx-of` command
Description
Add a command which uses a predicate and returns the first index where the predicate returns true.
Performs a linear search and stops on the first true
of the predicate.
Returns the index matched.
Design notes
- The name
idx-of
could also befind-idx
-
find
should be reserved for something which returns aTableRow
-
find-idx
would actually align with a futurefind
impl
-
- What to return on failure?
- This might be blocked on #156 if something like
Option
is wanted - Alternatively, a numeric like
-1
could be returned
- This might be blocked on #156 if something like
- Implement on all the iterables (
Table
,String
)
Alternatively, a numeric like
-1
could be returned
A use case is to find an index for insertion or skipping. In that case, a sensible return value would be beneficial and merits a considered design.