omega-rosetta
aien-dev/omega-rosetta
Brought by drakestapleton
omega-rosetta / drafts / rosettacode / rot-13.wiki
| 1 | =={{header|Omegese}}== |
| 2 | {{works with|omc|sha256 2c824805, aien-dev/omega-mv e5b32567, Linux AArch64}} |
| 3 | Omega has no imports, so the small output helpers (<code>emit</code> and friends) are part of the program. |
| 4 | <syntaxhighlight lang="text"> |
| 5 | om2 |
| 6 | text nl "\n" |
| 7 | text s1 "Hello, World!" |
| 8 | text s2 "The Quick Brown Fox Jumps Over The Lazy Dog." |
| 9 | note emit writes every byte of a to stdout; a short write is retried, an error exits 1 |
| 10 | fn emit a view uchar * to void |
| 11 | o = ulong 0 |
| 12 | while lt o len a bound 4096 |
| 13 | k = write 1 a o sub len a o |
| 14 | if le k 0 |
| 15 | exit 1 |
| 16 | end |
| 17 | o = add o ulong k |
| 18 | end |
| 19 | end |
| 20 | fn rot13 a view uchar * to void |
| 21 | r = new uchar 256 0 |
| 22 | for i ulong len a |
| 23 | c = get a i |
| 24 | if and ge c 65 le c 90 |
| 25 | c = add rem add sub c 65 13 26 65 |
| 26 | else |
| 27 | if and ge c 97 le c 122 |
| 28 | c = add rem add sub c 97 13 26 97 |
| 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 | rot13 s1 |
| 38 | rot13 s2 |
| 39 | ret 0 |
| 40 | end |
| 41 | </syntaxhighlight> |
| 42 | {{out}} |
| 43 | <pre> |
| 44 | Uryyb, Jbeyq! |
| 45 | Gur Dhvpx Oebja Sbk Whzcf Bire Gur Ynml Qbt. |
| 46 | </pre> |