Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/si/rosetta/tasks/string-case/string-case.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / si / rosetta / tasks / string-case / string-case.om` 42 lines ยท 864 bytes Raw Blame History 1 note Rosetta Code task "String case": https://rosettacode.org/wiki/String_case 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 text s "alphaBETA" 6 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 7 fn emit a view uchar * to void 8 o = ulong 0 9 while lt o len a bound 4096 10 k = write 1 a o sub len a o 11 if le k 0 12 exit 1 13 end 14 o = add o ulong k 15 end 16 end 17 note upper, lower and swap change ASCII letters only; strings up to 256 bytes (longer traps 3) 18 fn conv a view uchar * mode ulong to void 19 r = new uchar 256 0 20 for i ulong len a 21 c = get a i 22 up = and ge c 65 le c 90 23 lo = and ge c 97 le c 122 24 if and lo ne mode 1 25 c = sub c 32 26 else 27 if and up ne mode 0 28 c = add c 32 29 end 30 end 31 put r i c 32 end 33 emit part r 0 len a 34 emit nl 35 end 36 fn main to int 37 note mode 0 upper, 1 lower, 2 swap case 38 conv s 0 39 conv s 1 40 conv s 2 41 ret 0 42 end