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

40 lines · 854 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 s1 "asdf"
8text s2 "Hello, 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 reverses bytes, so it is correct for ASCII only; strings up to 256 bytes (longer traps 3)
21fn rev a view uchar * to void
22r = new uchar 256 0
23n = len a
24for i ulong n
25put r i get a sub sub n 1 i
26end
27emit part r 0 n
28emit nl
29end
30fn main to int
31rev s1
32rev s2
33ret 0
34end
35</syntaxhighlight>
36{{out}}
37<pre>
38fdsa
39!dlroW ,olleH
40</pre>