interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / si / rosetta / tasks / string-case / string-case.om

42 lines · 864 bytes Raw Blame History
1note Rosetta Code task "String case": https://rosettacode.org/wiki/String_case
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3om2
4text nl "\n"
5text s "alphaBETA"
6note emit writes every byte of a to stdout; a short write is retried, an error exits 1
7fn emit a view uchar * to void
8o = ulong 0
9while lt o len a bound 4096
10k = write 1 a o sub len a o
11if le k 0
12exit 1
13end
14o = add o ulong k
15end
16end
17note upper, lower and swap change ASCII letters only; strings up to 256 bytes (longer traps 3)
18fn conv a view uchar * mode ulong to void
19r = new uchar 256 0
20for i ulong len a
21c = get a i
22up = and ge c 65 le c 90
23lo = and ge c 97 le c 122
24if and lo ne mode 1
25c = sub c 32
26else
27if and up ne mode 0
28c = add c 32
29end
30end
31put r i c
32end
33emit part r 0 len a
34emit nl
35end
36fn main to int
37note mode 0 upper, 1 lower, 2 swap case
38conv s 0
39conv s 1
40conv s 2
41ret 0
42end