aboutsummaryrefslogtreecommitdiff
path: root/examples/learn/18-o3.zc
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
commitecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch)
tree70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /examples/learn/18-o3.zc
a
Diffstat (limited to 'examples/learn/18-o3.zc')
-rw-r--r--examples/learn/18-o3.zc10
1 files changed, 10 insertions, 0 deletions
diff --git a/examples/learn/18-o3.zc b/examples/learn/18-o3.zc
new file mode 100644
index 0000000..cb2237a
--- /dev/null
+++ b/examples/learn/18-o3.zc
@@ -0,0 +1,10 @@
+o3 int sum(fixed []int a) { int s = 0; for (int i = 0; i < len(a); i++) s += a[i]; return s; }
+fn main() {
+ fixed []int a = new(fixed []int, 5);
+ for (int i = 0; i < 5; i++) a[i] = i * i;
+ put_n(sum(a)); put_c(10);
+ o3 int hits = 0;
+ o3 { for (int i = 0; i < 1000; i++) if (i % 7 == 3) hits++; }
+ put_n(hits); put_c(10);
+ return 0;
+}