ogma icon indicating copy to clipboard operation
ogma copied to clipboard

[FEATURE] `idx-of` command

Open kurtlawrence opened this issue 1 year ago • 0 comments

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 be find-idx
    • find should be reserved for something which returns a TableRow
    • find-idx would actually align with a future find 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
  • 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.

kurtlawrence avatar Apr 03 '23 02:04 kurtlawrence