Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/ng/front/kernels/isort.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / ng / front / kernels / isort.om` 65 lines ยท 1227 bytes Raw Blame History 1 note isort: insertion sort of 20000 numbers from the generator of seed/rung4/tests/sort.om, in a 2 note global array; prints sum a[i]*(i+1), the count of unsorted neighbours, a[0] and a[19999]. 3 note OMC-EFF-2: main writes the nanoseconds between its two monons readings (the computation, without 4 note start-up and output) as one decimal line on stderr; stdout is unchanged. 5 global out uchar 32 6 global a ulong 20000 7 fn putnum fd int v ulong to void 8 put out 31 10 9 p = ulong 31 10 x = v 11 while gt x 9 12 p = sub p 1 13 put out p uchar add rem x 10 48 14 x = div x 10 15 end 16 p = sub p 1 17 put out p uchar add x 48 18 w = write fd out p sub 32 p 19 end 20 fn gen to void 21 x = ulong 12345 22 for i ulong 20000 23 x = rem add mul x `1103515245` 12345 `2147483648` 24 put a i rem x 100000 25 end 26 end 27 fn isort to void 28 for j ulong 20000 29 v = get a j 30 k = j 31 moving = true 32 while and moving gt k 0 33 p = get a sub k 1 34 if gt p v 35 put a k p 36 k = sub k 1 37 else 38 moving = false 39 end 40 end 41 put a k v 42 end 43 end 44 fn main to int 45 t0 = monons 46 gen 47 isort 48 s = ulong 0 49 for i ulong 20000 50 s = add s mul get a i add i 1 51 end 52 bad = ulong 0 53 for i ulong 19999 54 if gt get a i get a add i 1 55 bad = add bad 1 56 end 57 end 58 t1 = monons 59 putnum 2 ulong sub t1 t0 60 putnum 1 s 61 putnum 1 bad 62 putnum 1 get a 0 63 putnum 1 get a 19999 64 ret 0 65 end