interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / tasks / loops-continue / loops-continue.om

44 lines · 850 bytes Raw Blame History
1note Rosetta Code task "Loops/Continue": https://rosettacode.org/wiki/Loops/Continue
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3om2
4text nl "\n"
5text sep ", "
6note emit writes every byte of a to stdout; a short write is retried, an error exits 1
7fn emit a view uchar * to void
8o = ulong 0
9while lt o len a bound 4096
10k = write 1 a o sub len a o
11if le k 0
12exit 1
13end
14o = add o ulong k
15end
16end
17note emitu writes n in decimal; 20 digits hold every ulong
18fn emitu n ulong to void
19d = new uchar 20 0
20i = ulong 20
21v = n
22while true bound 20
23i = sub i 1
24put d i uchar add rem v 10 48
25v = div v 10
26if eq v 0
27break
28end
29end
30emit part d i sub 20 i
31end
32note 1 to 10; after a multiple of 5 a newline and continue, otherwise a separator
33fn main to int
34for k ulong 10
35i = add k 1
36emitu i
37if eq rem i 5 0
38emit nl
39continue
40end
41emit sep
42end
43ret 0
44end