Add builtin List.walkWithIndexUntil

This commit is contained in:
Bryce Miller 2023-12-11 23:04:40 -05:00
parent f795d0856a
commit 59eb28ef58
No known key found for this signature in database
GPG key ID: F1E97BF8DF152350
4 changed files with 46 additions and 0 deletions

View file

@ -990,6 +990,23 @@ fn list_walk_until_sum() {
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_walk_with_index_until_sum() {
assert_evals_to!(
r#"
List.walkWithIndexUntil [5, 7, 2, 3] 0 (\state, elem, index ->
if elem % 2 == 0 then
Break state
else
Continue (elem + index + state)
)
"#,
13,
i64
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn list_walk_implements_position() {