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/array-concatenation.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 / 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}}
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 text sp " "
8 note emit writes every byte of a to stdout; a short write is retried, an error exits 1
9 fn emit a view uchar * to void
10 o = ulong 0
11 while lt o len a bound 4096
12 k = write 1 a o sub len a o
13 if le k 0
14 exit 1
15 end
16 o = add o ulong k
17 end
18 end
19 note emitu writes n in decimal; 20 digits hold every ulong
20 fn emitu n ulong to void
21 d = new uchar 20 0
22 i = ulong 20
23 v = n
24 while true bound 20
25 i = sub i 1
26 put d i uchar add rem v 10 48
27 v = div v 10
28 if eq v 0
29 break
30 end
31 end
32 emit part d i sub 20 i
33 end
34 note cat copies x then y into r and returns the length
35 fn cat x view ulong * y view ulong * r edit ulong * to ulong
36 for i ulong len x
37 put r i get x i
38 end
39 for i ulong len y
40 put r add len x i get y i
41 end
42 ret add len x len y
43 end
44 fn main to int
45 a = new ulong 3 0
46 b = new ulong 4 0
47 c = new ulong 7 0
48 for i ulong 3
49 put a i add i 1
50 end
51 for i ulong 4
52 put b i add i 4
53 end
54 n = cat a b c
55 for i ulong n
56 if gt i 0
57 emit sp
58 end
59 emitu get c i
60 end
61 emit nl
62 ret 0
63 end
64
65 {{out}}
66
67 1 2 3 4 5 6 7
68