nx_find_first_positive.nx source
↩ module page · 26 lines · 796 B
1// nx_find_first_positive.nx -- AUTO-GENERATED from shape `array_find_index`.
2// Return index of first element satisfying the COND_BODY test; -1 if none.
3//
4// genealogy_id:
5// lineage_id: array_find_index
6// license: public_domain
7// complexity: O(n) worst, short-circuits on match
8
9// nx_safety_envelope:
10// intended_use: AUTO_APPLIED -- primitive-specific tuning queued
11// sil_target: SIL1
12// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail]
13// verdict: NOT_YET_EVALUATED
14
15import "nx_syscalls.nx"
16import "nx_tier.nx"
17
18func nx_find_first_positive(arr: *nx_int, n: nx_idx) -> nx_idx {
19 var i: nx_idx = 0
20 while i < n {
21 let v: nx_int = arr[i]
22 if v > 0 { return i }
23 i = i + 1
24 }
25 return -1
26}