mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
roc format List.roc
This commit is contained in:
parent
f216224495
commit
4a371b9524
1 changed files with 2 additions and 2 deletions
|
@ -826,7 +826,7 @@ findFirstIndex = \list, matcher ->
|
||||||
## If no satisfying element is found, an `Err NotFound` is returned.
|
## If no satisfying element is found, an `Err NotFound` is returned.
|
||||||
findLastIndex : List elem, (elem -> Bool) -> Result Nat [NotFound]*
|
findLastIndex : List elem, (elem -> Bool) -> Result Nat [NotFound]*
|
||||||
findLastIndex = \list, matches ->
|
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
|
if matches elem then
|
||||||
Break (prevIndex - 1)
|
Break (prevIndex - 1)
|
||||||
else
|
else
|
||||||
|
@ -927,7 +927,7 @@ splitFirst = \list, delimiter ->
|
||||||
when List.findFirstIndex list (\elem -> elem == delimiter) is
|
when List.findFirstIndex list (\elem -> elem == delimiter) is
|
||||||
Ok index ->
|
Ok index ->
|
||||||
before = List.sublist list { start: 0, len: 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 }
|
Ok { before, after }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue