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 / seed / ng / front / runs / isort-s.om

66 lines · 1304 bytes Raw Blame History
1note isort-s: kernels/isort.om with 4000 numbers (was 20000), for ngrun in gate-front-ir. isort:
2note insertion sort of numbers from the generator of seed/rung4/tests/sort.om, in a
3note global array; prints sum a[i]*(i+1), the count of unsorted neighbours, a[0] and a[3999].
4note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without
5note start-up and output) as one decimal line on stderr; stdout is unchanged.
6global out uchar 32
7global a ulong 4000
8fn putnum fd int v ulong to void
9put out 31 10
10p = ulong 31
11x = v
12while gt x 9
13p = sub p 1
14put out p uchar add rem x 10 48
15x = div x 10
16end
17p = sub p 1
18put out p uchar add x 48
19w = write fd out p sub 32 p
20end
21fn gen to void
22x = ulong 12345
23for i ulong 4000
24x = rem add mul x 1103515245 12345 2147483648
25put a i rem x 100000
26end
27end
28fn isort to void
29for j ulong 4000
30v = get a j
31k = j
32moving = true
33while and moving gt k 0
34p = get a sub k 1
35if gt p v
36put a k p
37k = sub k 1
38else
39moving = false
40end
41end
42put a k v
43end
44end
45fn main to int
46t0 = monons
47gen
48isort
49s = ulong 0
50for i ulong 4000
51s = add s mul get a i add i 1
52end
53bad = ulong 0
54for i ulong 3999
55if gt get a i get a add i 1
56bad = add bad 1
57end
58end
59t1 = monons
60putnum 2 ulong sub t1 t0
61putnum 1 s
62putnum 1 bad
63putnum 1 get a 0
64putnum 1 get a 3999
65ret 0
66end