mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-25 13:36:37 +00:00
builtin(list): expose walkTry
Fixes: #4168 Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
This commit is contained in:
parent
5de2661223
commit
0f96dddc25
2 changed files with 2 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue