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-rosetta/blob/main/drafts/rosettacode/loops-break.wiki
# omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
Sign in to star 0 stars 0 watching
About Files History Releases Proposed changes Issues For developers
branch `main` Branches Tags History
`omega-rosetta / drafts / rosettacode / loops-break.wiki`
79 lines ยท 1343 bytes Raw Blame History
1 =={{header|Omegese}}==
2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}}
3 Omega has no imports, so the small output helpers (emit and friends) are part of the program.
4
5 om2
6 text nl "\n"
7 note emit writes every byte of a to stdout; a short write is retried, an error exits 1
8 fn emit a view uchar * to void
9 o = ulong 0
10 while lt o len a bound 4096
11 k = write 1 a o sub len a o
12 if le k 0
13 exit 1
14 end
15 o = add o ulong k
16 end
17 end
18 note emitu writes n in decimal; 20 digits hold every ulong
19 fn emitu n ulong to void
20 d = new uchar 20 0
21 i = ulong 20
22 v = n
23 while true bound 20
24 i = sub i 1
25 put d i uchar add rem v 10 48
26 v = div v 10
27 if eq v 0
28 break
29 end
30 end
31 emit part d i sub 20 i
32 end
33 note a fixed linear congruential generator stands in for a random source (Rosetta asks for
34 note random numbers 0..19): x' = (`1103515245` x + 12345) mod 2^31, r = (x' / 65536) mod 20.
35 note Print r; stop after printing 10; otherwise print the next value too
36 fn main to int
37 x = ulong 42
38 while true bound 1000
39 x = and add mul x `1103515245` 12345 `2147483647`
40 r = rem div x 65536 20
41 emitu r
42 emit nl
43 if eq r 10
44 break
45 end
46 x = and add mul x `1103515245` 12345 `2147483647`
47 emitu rem div x 65536 20
48 emit nl
49 end
50 ret 0
51 end
52
53 {{out}}
54
55 1
56 13
57 9
58 1
59 16
60 13
61 17
62 0
63 5
64 5
65 12
66 14
67 14
68 8
69 13
70 ...
71 0
72 5
73 15
74 14
75 6
76 15
77 14
78 10
79