nx_count_one.nx source
↩ module page · 27 lines · 812 B
1// nx_count_one.nx -- AUTO-GENERATED from shape `array_count_predicate`.
2// Count array elements satisfying if v == 1 { count = count + 1 } (an `if ... { count = count + 1 }`).
3//
4// genealogy_id:
5// lineage_id: array_count
6// license: public_domain
7// complexity: O(n)
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_count_one(arr: *nx_int, n: nx_idx) -> nx_int {
19 var count: nx_int = 0
20 var i: nx_idx = 0
21 while i < n {
22 let v: nx_int = arr[i]
23 if v == 1 { count = count + 1 }
24 i = i + 1
25 }
26 return count
27}