interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / fixtures / fib.om

29 lines · 429 bytes Raw Blame History
1note recursive fib(n) for n = 0 .. 25, one number per line
2global out uchar 32
3fn fib n ulong to ulong
4if lt n 2
5ret n
6end
7a = fib sub n 1
8b = fib sub n 2
9ret add a b
10end
11fn putnum v ulong to void
12put out 31 10
13p = ulong 31
14x = v
15while gt x 9
16p = sub p 1
17put out p uchar add rem x 10 48
18x = div x 10
19end
20p = sub p 1
21put out p uchar add x 48
22w = write 1 out p sub 32 p
23end
24fn main to int
25for i ulong 26
26putnum fib i
27end
28ret 0
29end