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 / struct-bool / neighbours.om

33 lines · 776 bytes Raw Blame History
1note neighbours.om: put on a bool field must not touch the fields around it, and a put on a
2note neighbour must not touch the bool. Fields a=11 f=true b=22 g=false c=33; f is put false,
3note g is put true. Bits: f false 1, g true 2, a+b+c = 66 (total 69). Then a b c become 1 2 3:
4note f false 4, g true 8, a+b+c = 6. Result 69 + 12 + 6 = 87.
5struct N a uint f bool b uint g bool c uchar end
6fn main to uint
7n = new N 11 true 22 false 33
8put n f false
9put n g true
10r = uint 0
11if eq get n f false
12r = add r 1
13end
14if eq get n g true
15r = add r 2
16end
17r = add r get n a
18r = add r get n b
19r = add r uint get n c
20put n a 1
21put n b 2
22put n c 3
23if eq get n f false
24r = add r 4
25end
26if eq get n g true
27r = add r 8
28end
29r = add r get n a
30r = add r get n b
31r = add r uint get n c
32ret r
33end