29 lines
682 B
Plaintext
29 lines
682 B
Plaintext
choose: (bit, i32, i32) -> i32: @ (condition: bit, when_true: i32, when_false: i32) { if condition { when_true } else { when_false } }
|
|
|
|
choose_block: (bit, i32, i32) -> i32: @ (condition: bit, when_true: i32, when_false: i32) { if condition {
|
|
when_true
|
|
} else if not condition {
|
|
when_false
|
|
} else {
|
|
0
|
|
} }
|
|
|
|
first_positive: []i32 -> i32?: @ values: []i32 {
|
|
for value in values {
|
|
if value > 0 {
|
|
return value->|.some
|
|
}
|
|
}
|
|
nil
|
|
}
|
|
|
|
labelled_search: []i32 -> i32: @ values: []i32 { loop `outer {
|
|
for value in values `items {
|
|
if value > 0 {
|
|
break `outer value
|
|
}
|
|
continue `items
|
|
}
|
|
break 0
|
|
} }
|