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/si/rosetta/tasks/loops-break/loops-break.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 / si / rosetta / tasks / loops-break / loops-break.om` 49 lines ยท 1142 bytes Raw Blame History 1 note Rosetta Code task "Loops/Break": https://rosettacode.org/wiki/Loops/Break 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 6 fn emit a view uchar * to void 7 o = ulong 0 8 while lt o len a bound 4096 9 k = write 1 a o sub len a o 10 if le k 0 11 exit 1 12 end 13 o = add o ulong k 14 end 15 end 16 note emitu writes n in decimal; 20 digits hold every ulong 17 fn emitu n ulong to void 18 d = new uchar 20 0 19 i = ulong 20 20 v = n 21 while true bound 20 22 i = sub i 1 23 put d i uchar add rem v 10 48 24 v = div v 10 25 if eq v 0 26 break 27 end 28 end 29 emit part d i sub 20 i 30 end 31 note a fixed linear congruential generator stands in for a random source (Rosetta asks for 32 note random numbers 0..19): x' = (`1103515245` x + 12345) mod 2^31, r = (x' / 65536) mod 20. 33 note Print r; stop after printing 10; otherwise print the next value too 34 fn main to int 35 x = ulong 42 36 while true bound 1000 37 x = and add mul x `1103515245` 12345 `2147483647` 38 r = rem div x 65536 20 39 emitu r 40 emit nl 41 if eq r 10 42 break 43 end 44 x = and add mul x `1103515245` 12345 `2147483647` 45 emitu rem div x 65536 20 46 emit nl 47 end 48 ret 0 49 end