interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / bench / omc_efficiency / kernels / om2 / fib.om

34 lines · 697 bytes Raw Blame History
1note fib: doubly recursive Fibonacci of 38 (ulong); prints fib(38). Call and return heavy.
2note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without
3note start-up and output) as one decimal line on stderr; stdout is unchanged.
4om2
5global obuf uchar 32
6fn putnum fd int v ulong to void
7put obuf 31 10
8p = ulong 31
9x = v
10while gt x 9
11p = sub p 1
12put obuf p uchar add rem x 10 48
13x = div x 10
14end
15p = sub p 1
16put obuf p uchar add x 48
17w = write fd obuf p sub 32 p
18end
19fn fib n ulong to ulong
20if lt n 2
21ret n
22end
23a = fib sub n 1
24b = fib sub n 2
25ret add a b
26end
27fn main to int
28t0 = monons
29r = fib 38
30t1 = monons
31putnum 2 ulong sub t1 t0
32putnum 1 r
33ret 0
34end