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 / train / omega-llm / tools / contrast / contrast.om

171 lines · 3064 bytes Raw Blame History
1note Build after wbuild.om. Write adjacent contrasting records to standard output.
2text ctl "fn "
3text hint "note "
4text spc " "
5text nl "\n"
6text fin "\nend\n"
7text retprefix "ret "
8text sig " ulong "
9text viewarg " view ulong "
10text tail " ulong to ulong\n"
11text lefts "a|x|left|first|u|val|"
12text rights "b|y|right|second|v|other|"
13text arrays "a|items|data|buf|values|arr|"
14text sizes "n|count|size|used|limit|length|"
15text names "calc|apply|compute|measure|reduce|value|"
16text verbs "return |compute |find |give |calculate |report |"
17text tasks "the absolute difference|the sum|the smaller value|the larger value|the bitwise exclusive OR|the product|the XOR of the first entries|the sum of the first entries|the largest of the first entries|the number of zeros in the first entries|"
18text other "the unsigned gap between the two operands|both values added together|the minimum of the two operands|the maximum of the two operands|the bitwise XOR of the operands|both values multiplied together|the bitwise exclusive OR of the prefix|the total across the prefix|the prefix maximum|the count of zeros in the prefix|"
19text adds "add "
20text muls "mul "
21text xors "xor "
22text subs "sub "
23text less "if lt "
24text greater "if gt "
25text closeelse "\nend\nret "
26text start "s = ulong 0\nfor i ulong "
27text value "get "
28text index " i"
29text acc "\ns = "
30text zero "\nif eq "
31text maxcond "\nif gt "
32text assign " s\ns = "
33text incr " 0\ns = add s 1"
34text finishloop "\nend\nret s"
35text endinside "\nend"
36text accum "s "
37fn entry table view uchar * which ulong to void
38k = ulong 0
39for i ulong len table
40v = get table i
41if eq v 124
42if eq k which
43ret
44end
45k = add k 1
46else
47if eq k which
48wdoc ulong v
49end
50end
51end
52exit 72
53end
54fn pair v ulong reverse bool to void
55if reverse
56entry rights v
57wdot spc
58entry lefts v
59else
60entry lefts v
61wdot spc
62entry rights v
63end
64end
65fn readitem v ulong to void
66wdot value
67entry arrays v
68wdot index
69end
70fn body op ulong v ulong to void
71if lt op 6
72if or eq op 0 or eq op 2 eq op 3
73if eq op 3
74wdot greater
75else
76wdot less
77end
78pair v false
79wdot nl
80wdot retprefix
81if eq op 0
82wdot subs
83pair v true
84wdot closeelse
85wdot subs
86pair v false
87else
88entry lefts v
89wdot closeelse
90entry rights v
91end
92else
93wdot retprefix
94if eq op 1
95wdot adds
96else
97if eq op 4
98wdot xors
99else
100wdot muls
101end
102end
103pair v false
104end
105else
106wdot start
107entry sizes v
108if lt op 8
109wdot acc
110if eq op 6
111wdot xors
112else
113wdot adds
114end
115wdot accum
116readitem v
117else
118if eq op 8
119wdot maxcond
120readitem v
121wdot assign
122readitem v
123else
124wdot zero
125readitem v
126wdot incr
127end
128wdot endinside
129end
130wdot finishloop
131end
132wdot fin
133end
134fn main to int
135put wdofd 0 1
136for g ulong 144
137v = rem g 6
138nam = rem add div g 6 rem g 6 6
139verb = rem add div g 36 div g 6 6
140for j ulong 10
141op = rem add mul j 7 g 10
142wdoc 0
143wdot hint
144entry verbs verb
145if eq rem div g 6 2 0
146entry tasks op
147else
148entry other op
149end
150wdot nl
151wdot ctl
152entry names nam
153wdot spc
154if lt op 6
155entry lefts v
156wdot sig
157entry rights v
158else
159entry arrays v
160wdot viewarg
161wdod add 4 mul 4 rem div g 6 4
162wdot spc
163entry sizes v
164end
165wdot tail
166body op v
167end
168end
169wdoflush 1
170ret 0
171end