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/drafts/rosettacode/phrase-reversals.wiki # 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 / drafts / rosettacode / phrase-reversals.wiki` 81 lines ยท 1563 bytes Raw Blame History 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 (emit and friends) are part of the program. 4 5 om2 6 text nl "\n" 7 text sp " " 8 text msg "rosetta code phrase reversal" 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 note emitc writes one byte 21 fn emitc c uchar to void 22 b = new uchar 1 0 23 put b 0 c 24 emit b 25 end 26 note words splits a into (start, length) pairs at single spaces and returns how many 27 fn words a view uchar * st edit ulong 16 ln edit ulong 16 to ulong 28 k = ulong 0 29 s = ulong 0 30 for i ulong add len a 1 31 e = eq i len a 32 if not e 33 e = eq get a i 32 34 end 35 if e 36 put st k s 37 put ln k sub i s 38 k = add k 1 39 s = add i 1 40 end 41 end 42 ret k 43 end 44 fn revb a view uchar * to void 45 for i ulong len a 46 emitc get a sub sub len a 1 i 47 end 48 end 49 fn main to int 50 st = new ulong 16 0 51 ln = new ulong 16 0 52 k = words msg st ln 53 note 1: the whole string reversed 54 revb msg 55 emit nl 56 note 2: each word reversed, order kept 57 for w ulong k 58 if gt w 0 59 emit sp 60 end 61 revb part msg get st w get ln w 62 end 63 emit nl 64 note 3: the word order reversed, words kept 65 for w ulong k 66 if gt w 0 67 emit sp 68 end 69 x = sub sub k 1 w 70 emit part msg get st x get ln x 71 end 72 emit nl 73 ret 0 74 end 75 76 {{out}} 77

78 lasrever esarhp edoc attesor

79 attesor edoc esarhp lasrever

80 reversal phrase code rosetta

81