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
omega-mv / si / benchmarks / native / neuralese / nl1r / mutate.om
| 1 | note Standalone with io.om. Protocol test data mutation, not a scorer or learned arm. |
| 2 | global MB uchar 131072 |
| 3 | text MC "," |
| 4 | fn mcopy begin ulong finish ulong to void |
| 5 | p = begin |
| 6 | while lt p finish |
| 7 | n = write 1 MB p sub finish p |
| 8 | if le n 0 |
| 9 | exit 93 |
| 10 | end |
| 11 | p = add p ulong n |
| 12 | end |
| 13 | end |
| 14 | fn mseek p ulong stop ulong delim uchar to ulong |
| 15 | while lt p stop |
| 16 | if eq get MB p delim |
| 17 | ret p |
| 18 | end |
| 19 | p = add p 1 |
| 20 | end |
| 21 | ret p |
| 22 | end |
| 23 | fn mreplace n ulong col ulong v ulong header bool to int |
| 24 | start = ulong 0 |
| 25 | while lt start n |
| 26 | finish = mseek start n uchar 10 |
| 27 | want = eq get MB start 82 |
| 28 | if header |
| 29 | want = eq get MB start 67 |
| 30 | end |
| 31 | if want |
| 32 | p = add start 2 |
| 33 | for k ulong col |
| 34 | p = mseek p finish uchar 44 |
| 35 | p = add p 1 |
| 36 | end |
| 37 | endpos = mseek p finish uchar 44 |
| 38 | if or gt p finish gt endpos finish |
| 39 | ret 90 |
| 40 | end |
| 41 | mcopy 0 p |
| 42 | jnumber v |
| 43 | mcopy endpos n |
| 44 | ret 0 |
| 45 | end |
| 46 | start = add finish 1 |
| 47 | end |
| 48 | ret 90 |
| 49 | end |
| 50 | fn main to int |
| 51 | if ne argcnt 2 |
| 52 | ret 90 |
| 53 | end |
| 54 | ab = new uchar 2 0 |
| 55 | an = argread 1 ab 0 2 |
| 56 | mode = ulong 0 |
| 57 | for k ulong ulong an |
| 58 | mode = add mul mode 10 ulong sub get ab k 48 |
| 59 | end |
| 60 | n = ulong 0 |
| 61 | while lt n 131072 |
| 62 | r = read 0 MB n sub ulong 131072 n |
| 63 | if lt r 0 |
| 64 | ret 90 |
| 65 | end |
| 66 | if eq r 0 |
| 67 | break |
| 68 | end |
| 69 | n = add n ulong r |
| 70 | end |
| 71 | if eq n 131072 |
| 72 | ret 90 |
| 73 | end |
| 74 | col = ulong 49 |
| 75 | v = ulong 1 |
| 76 | if eq mode 2 |
| 77 | col = 48 |
| 78 | v = 7 |
| 79 | end |
| 80 | if eq mode 3 |
| 81 | col = 35 |
| 82 | end |
| 83 | if eq mode 4 |
| 84 | col = 36 |
| 85 | v = bitcast ulong 0.25f64 |
| 86 | end |
| 87 | if eq mode 5 |
| 88 | col = 40 |
| 89 | end |
| 90 | if eq mode 6 |
| 91 | col = 44 |
| 92 | end |
| 93 | if eq mode 7 |
| 94 | col = 0 |
| 95 | end |
| 96 | if eq mode 8 |
| 97 | col = 47 |
| 98 | v = 2 |
| 99 | end |
| 100 | ret mreplace n col v eq mode 7 |
| 101 | end |