roc format List.roc

This commit is contained in:
Richard Feldman 2022-07-23 22:52:02 -04:00 committed by Folkert
parent f216224495
commit 4a371b9524
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -826,7 +826,7 @@ findFirstIndex = \list, matcher ->
## If no satisfying element is found, an `Err NotFound` is returned.
findLastIndex : List elem, (elem -> Bool) -> Result Nat [NotFound]*
findLastIndex = \list, matches ->
foundIndex = List.iterateBackwards list (List.len list) \prevIndex, elem ->
foundIndex = List.iterateBackwards list (List.len list) \prevIndex, elem ->
if matches elem then
Break (prevIndex - 1)
else
@ -927,7 +927,7 @@ splitFirst = \list, delimiter ->
when List.findFirstIndex list (\elem -> elem == delimiter) is
Ok index ->
before = List.sublist list { start: 0, len: index }
after = List.sublist list { start: index + 1, len: List.len list - index - 1}
after = List.sublist list { start: index + 1, len: List.len list - index - 1 }
Ok { before, after }