Merge pull request #4227 from snprajwal/list-expose-walktry

builtin(list): expose walkTry
This commit is contained in:
Ayaz 2022-10-07 09:45:21 -05:00 committed by GitHub
commit addfa29a56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -39,6 +39,7 @@ interface List
max,
map4,
mapTry,
walkTry,
dropFirst,
joinMap,
any,
@ -959,9 +960,8 @@ mapTry = \list, toResult ->
Result.map (toResult elem) \ok ->
List.append state ok
## This is the same as `iterate` but with Result instead of [Continue, Break].
## This is the same as `iterate` but with [Result] instead of `[Continue, Break]`.
## Using `Result` saves a conditional in `mapTry`.
## It might be useful to expose this in userspace?
walkTry : List elem, state, (state, elem -> Result state err) -> Result state err
walkTry = \list, init, func ->
walkTryHelp list init func 0 (List.len list)