mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
Merge remote-tracking branch 'origin/trunk' into box-all-the-things
This commit is contained in:
commit
e90c12ba1f
11 changed files with 191 additions and 131 deletions
|
@ -798,6 +798,34 @@ fn list_walk_until_sum() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn list_walk_imlements_position() {
|
||||
assert_evals_to!(
|
||||
r#"
|
||||
Option a : [ Some a, None ]
|
||||
|
||||
find : List a, a -> Option Nat
|
||||
find = \list, needle ->
|
||||
findHelp list needle
|
||||
|> .v
|
||||
|
||||
findHelp = \list, needle ->
|
||||
List.walkUntil list { n: 0, v: None } \{ n, v }, element ->
|
||||
if element == needle then
|
||||
Stop { n, v: Some n }
|
||||
else
|
||||
Continue { n: n + 1, v }
|
||||
|
||||
when find [ 1, 2, 3 ] 3 is
|
||||
None -> 0
|
||||
Some v -> v
|
||||
"#,
|
||||
2,
|
||||
i64
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn list_walk_until_even_prefix_sum() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue