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 / string-append.wiki

40 lines · 998 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 s0 "Hello,"
8text more " World!"
9note emit writes every byte of a to stdout; a short write is retried, an error exits 1
10fn emit a view uchar * to void
11o = ulong 0
12while lt o len a bound 4096
13k = write 1 a o sub len a o
14if le k 0
15exit 1
16end
17o = add o ulong k
18end
19end
20note copyto copies s into d at offset off and returns the offset after it (past the end traps 3)
21fn copyto d edit uchar * off ulong s view uchar * to ulong
22for i ulong len s
23put d add off i get s i
24end
25ret add off len s
26end
27fn main to int
28note the string lives in a 64-byte buffer b with length n; appending copies after byte n
29b = new uchar 64 0
30n = copyto b 0 s0
31n = copyto b n more
32emit part b 0 n
33emit nl
34ret 0
35end
36</syntaxhighlight>
37{{out}}
38<pre>
39Hello, World!
40</pre>