interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / drafts / rosettacode / array-concatenation.wiki

68 lines · 1251 bytes Raw Blame History
1=={{header|Omegese}}==
2{{works with|omc|sha256 2c824805, aien-dev/omega-mv e5b32567, Linux AArch64}}
3Omega has no imports, so the small output helpers (<code>emit</code> and friends) are part of the program.
4<syntaxhighlight lang="text">
5om2
6text nl "\n"
7text sp " "
8note emit writes every byte of a to stdout; a short write is retried, an error exits 1
9fn emit a view uchar * to void
10o = ulong 0
11while lt o len a bound 4096
12k = write 1 a o sub len a o
13if le k 0
14exit 1
15end
16o = add o ulong k
17end
18end
19note emitu writes n in decimal; 20 digits hold every ulong
20fn emitu n ulong to void
21d = new uchar 20 0
22i = ulong 20
23v = n
24while true bound 20
25i = sub i 1
26put d i uchar add rem v 10 48
27v = div v 10
28if eq v 0
29break
30end
31end
32emit part d i sub 20 i
33end
34note cat copies x then y into r and returns the length
35fn cat x view ulong * y view ulong * r edit ulong * to ulong
36for i ulong len x
37put r i get x i
38end
39for i ulong len y
40put r add len x i get y i
41end
42ret add len x len y
43end
44fn main to int
45a = new ulong 3 0
46b = new ulong 4 0
47c = new ulong 7 0
48for i ulong 3
49put a i add i 1
50end
51for i ulong 4
52put b i add i 4
53end
54n = cat a b c
55for i ulong n
56if gt i 0
57emit sp
58end
59emitu get c i
60end
61emit nl
62ret 0
63end
64</syntaxhighlight>
65{{out}}
66<pre>
671 2 3 4 5 6 7
68</pre>