code wiki / (root) / nx_all_even.nx

nx_all_even.nx source

↩ module page · 30 lines · 980 B

1// nx_all_even.nx -- AUTO-GENERATED from shape `array_predicate`. 2// 3// Shape: read-only scan returning 1 (predicate satisfied) or 0. 4// The SHORTCIRCUIT_BODY is the per-element test; the loop iterates 5// until exhaustion or the body returns early. DEFAULT_RETURN is 6// what the function returns if no element triggers short-circuit. 7// 8// genealogy_id: 9// lineage_id: array_predicate 10// license: public_domain 11// complexity: O(n) worst case, may short-circuit 12 13// nx_safety_envelope: 14// intended_use: AUTO_APPLIED -- primitive-specific tuning queued 15// sil_target: SIL1 16// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail] 17// verdict: NOT_YET_EVALUATED 18 19import "nx_syscalls.nx" 20import "nx_tier.nx" 21 22func nx_all_even(arr: *nx_int, n: nx_idx) -> nx_int { 23 var i: nx_idx = 0 24 while i < n { 25 let v: nx_int = arr[i] 26 if (v - (v / 2) * 2) != 0 { return 0 } 27 i = i + 1 28 } 29 return 1 30}