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 / mix.om

109 lines · 1851 bytes Raw Blame History
1om2
2note Shuffle complete NUL-prefixed records from the two source files.
3text old "old.om"
4text newpath "contrast.om"
5text target "mixed.om"
6global corpus uchar *
7global starts ulong *
8global ids ulong *
9fn append path view uchar * to void
10fd = int fopen path 0 len path 0 0
11if lt fd 0
12exit 70
13end
14size = fseek fd 0 2
15if le size 0
16exit 72
17end
18if ne fseek fd 0 0 0
19exit 70
20end
21base = len corpus
22stop = add base ulong size
23if le stop base
24exit 70
25end
26rc = enlarge corpus stop
27if lt rc 0
28exit 70
29end
30off = base
31for attempt ulong ulong size bound 9223372036854775807
32n = read fd corpus off sub stop off
33if le n 0
34exit 70
35end
36off = add off ulong n
37if eq off stop
38break
39end
40end
41if ne fclose fd 0
42exit 70
43end
44if ne get corpus base 0
45exit 72
46end
47end
48fn makeindex to ulong
49count = ulong 0
50for i ulong len corpus bound 9223372036854775807
51if eq get corpus i 0
52count = add count 1
53end
54end
55rc = enlarge starts add count 1
56if lt rc 0
57exit 70
58end
59rc = enlarge ids count
60if lt rc 0
61exit 70
62end
63k = ulong 0
64for i ulong len corpus bound 9223372036854775807
65if eq get corpus i 0
66put starts k i
67put ids k k
68k = add k 1
69end
70end
71put starts count len corpus
72ret count
73end
74fn putrecord fd int k ulong to void
75off = get starts k
76stop = get starts add k 1
77for attempt ulong sub stop off bound 9223372036854775807
78r = write fd corpus off sub stop off
79if le r 0
80exit 70
81end
82off = add off ulong r
83if eq off stop
84ret
85end
86end
87end
88fn main to int
89append old
90append newpath
91n = makeindex
92seed = ulong 123456789
93for i ulong sub n 1 bound 9223372036854775807
94last = sub sub n i 1
95seed = add mul seed 6364136223846793005 1442695040888963407
96j = rem shr seed 16 add last 1
97tmp = get ids last
98put ids last get ids j
99put ids j tmp
100end
101fd = int fopen target 0 len target 193 384
102if lt fd 0
103ret 70
104end
105for i ulong n bound 9223372036854775807
106putrecord fd get ids i
107end
108ret int fclose fd
109end