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-case.wiki

51 lines · 1032 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 s "alphaBETA"
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 upper, lower and swap change ASCII letters only; strings up to 256 bytes (longer traps 3)
20fn conv a view uchar * mode ulong to void
21r = new uchar 256 0
22for i ulong len a
23c = get a i
24up = and ge c 65 le c 90
25lo = and ge c 97 le c 122
26if and lo ne mode 1
27c = sub c 32
28else
29if and up ne mode 0
30c = add c 32
31end
32end
33put r i c
34end
35emit part r 0 len a
36emit nl
37end
38fn main to int
39note mode 0 upper, 1 lower, 2 swap case
40conv s 0
41conv s 1
42conv s 2
43ret 0
44end
45</syntaxhighlight>
46{{out}}
47<pre>
48ALPHABETA
49alphabeta
50ALPHAbeta
51</pre>