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 / omc / tests / pools / gr.om

60 lines · 1106 bytes Raw Blame History
1note gate-pools 3: a uchar pool filled by read 0 P off n from a pipe, n given by a function that enlarges P
2note (and a blocker B above it) by 65536 elements before every read; then the bytes are written back and their
3note count printed. The gate feeds it `seq 1 200000` through a pipe; its expected output is built there.
4global B uchar *
5global P uchar *
6global ob uchar 24
7fn pnum v ulong to void
8put ob 23 10
9i = ulong 23
10x = v
11go = true
12while go bound 21
13i = sub i 1
14put ob i uchar add rem x 10 48
15x = div x 10
16go = ne x 0
17end
18k = write 1 ob i sub 24 i
19end
20fn plong v long to void
21if lt v 0
22put ob 0 uchar 45
23k = write 1 ob 0 1
24pnum ulong neg v
25else
26pnum ulong v
27end
28end
29fn gn n ulong to ulong
30r = enlarge B add len B 4096
31r = enlarge P add len P n
32ret n
33end
34fn main to int
35r = enlarge B ulong 1
36r = enlarge P ulong 1
37used = ulong 0
38go = true
39while go bound 100000
40k = read 0 P used gn 65536
41if lt k 0
42ret 2
43end
44if eq k 0
45go = false
46else
47used = add used ulong k
48end
49end
50o = ulong 0
51while lt o used bound 100000
52k = write 1 P o sub used o
53if le k 0
54ret 3
55end
56o = add o ulong k
57end
58pnum used
59ret 0
60end