code wiki / (root) / nx_xor_all.nx

nx_xor_all.nx source

↩ module page · 29 lines · 899 B

1// nx_xor_all.nx -- AUTO-GENERATED from shape `accumulator_over_array`. 2// 3// Shape: read-only fold over a *nx_int array of length nx_idx; returns 4// an accumulated nx_int. 0 = initial accumulator value. 5// acc = acc ^ arr[i] = single-line statement that updates `acc` from arr[i]. 6// 7// genealogy_id: classical_xor_reduce 8// lineage_id: array_fold 9// license: public_domain 10// complexity: O(n) single pass 11 12// nx_safety_envelope: 13// intended_use: AUTO_APPLIED -- primitive-specific tuning queued 14// sil_target: SIL1 15// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail] 16// verdict: NOT_YET_EVALUATED 17 18import "nx_syscalls.nx" 19import "nx_tier.nx" 20 21func nx_xor_all(arr: *nx_int, n: nx_idx) -> nx_int { 22 var acc: nx_int = 0 23 var i: nx_idx = 0 24 while i < n { 25 acc = acc ^ arr[i] 26 i = i + 1 27 } 28 return acc 29}