interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / tasks / string-concatenation / string-concatenation.om

34 lines · 792 bytes Raw Blame History
1note Rosetta Code task "String concatenation": https://rosettacode.org/wiki/String_concatenation
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3om2
4text nl "\n"
5text str "hello"
6text lit " literal"
7note emit writes every byte of a to stdout; a short write is retried, an error exits 1
8fn emit a view uchar * to void
9o = ulong 0
10while lt o len a bound 4096
11k = write 1 a o sub len a o
12if le k 0
13exit 1
14end
15o = add o ulong k
16end
17end
18note copyto copies s into d at offset off and returns the offset after it (past the end traps 3)
19fn copyto d edit uchar * off ulong s view uchar * to ulong
20for i ulong len s
21put d add off i get s i
22end
23ret add off len s
24end
25fn main to int
26emit str
27emit nl
28b = new uchar 64 0
29p = copyto b 0 str
30p = copyto b p lit
31emit part b 0 p
32emit nl
33ret 0
34end