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 / research / om-bench / controls / brk-mut.om

60 lines · 809 bytes Raw Blame History
1note Read unsigned decimal numbers separated by spaces or newlines from stdin; print their sum.
2global inb uchar 65536
3global outb uchar 32
4fn readall to ulong
5n = ulong 0
6while lt n 65536 bound 65537
7k = read 0 inb n sub 65536 n
8if lt k 0
9exit 2
10end
11if eq k 0
12break
13end
14n = add n ulong k
15end
16ret n
17end
18fn printu v ulong to void
19i = ulong 31
20put outb i 10
21x = v
22while true bound 21
23i = sub i 1
24put outb i uchar add rem x 10 48
25x = div x 10
26if eq x 0
27break
28end
29end
30off = i
31k = write 1 outb off sub 32 off
32if ne k long sub 32 off
33exit 3
34end
35end
36text yes "yes\n"
37text no "no\n"
38fn main to int
39n = readall
40d = long 0
41ok = true
42for i ulong n
43c = get inb i
44if eq c 40
45d = add d 1
46end
47if eq c 41
48d = sub d 1
49if lt d 0
50ok = false
51end
52end
53end
54if ok
55k = write 1 yes 0 len yes
56else
57k = write 1 no 0 len no
58end
59ret 0
60end