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-rosetta/blob/main/tasks/reverse-a-string/reverse-a-string.om # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / tasks / reverse-a-string / reverse-a-string.om` 32 lines ยท 707 bytes Raw Blame History 1 note Rosetta Code task "Reverse a string": https://rosettacode.org/wiki/Reverse_a_string 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 text s1 "asdf" 6 text s2 "Hello, World!" 7 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 8 fn emit a view uchar * to void 9 o = ulong 0 10 while lt o len a bound 4096 11 k = write 1 a o sub len a o 12 if le k 0 13 exit 1 14 end 15 o = add o ulong k 16 end 17 end 18 note reverses bytes, so it is correct for ASCII only; strings up to 256 bytes (longer traps 3) 19 fn rev a view uchar * to void 20 r = new uchar 256 0 21 n = len a 22 for i ulong n 23 put r i get a sub sub n 1 i 24 end 25 emit part r 0 n 26 emit nl 27 end 28 fn main to int 29 rev s1 30 rev s2 31 ret 0 32 end