builtin(list): expose walkTry

Fixes: #4168

Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
This commit is contained in:
Prajwal S N 2022-10-07 00:03:18 +05:30
parent 5de2661223
commit 0f96dddc25
No known key found for this signature in database
GPG key ID: D0FECEE245BC2695
2 changed files with 2 additions and 1 deletions

View file

@ -39,6 +39,7 @@ interface List
max,
map4,
mapTry,
walkTry,
dropFirst,
joinMap,
any,
@ -959,7 +960,6 @@ mapTry = \list, toResult ->
## 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)

View file

@ -1373,6 +1373,7 @@ define_builtins! {
72 LIST_SUBLIST_LOWLEVEL: "sublistLowlevel"
73 LIST_CAPACITY: "capacity"
74 LIST_MAP_TRY: "mapTry"
75 LIST_WALK_TRY: "walkTry"
}
7 RESULT: "Result" => {
0 RESULT_RESULT: "Result" exposed_type=true // the Result.Result type alias