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/string-comparison.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 / string-comparison.wiki` 97 lines ยท 1705 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 a1 "alpha" 9 text b1 "beta" 10 text a2 "Hello" 11 text b2 "hello" 12 text a3 "abc" 13 text b3 "abcd" 14 text teq " eq=" 15 text tlt " lt=" 16 text tgt " gt=" 17 text tci " equal-ignoring-case=" 18 text tyes "yes" 19 text tno "no" 20 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 21 fn emit a view uchar * to void 22 o = ulong 0 23 while lt o len a bound 4096 24 k = write 1 a o sub len a o 25 if le k 0 26 exit 1 27 end 28 o = add o ulong k 29 end 30 end 31 fn emitb b bool to void 32 if b 33 emit tyes 34 else 35 emit tno 36 end 37 end 38 note cmp is byte order: -1, 0 or 1; a proper prefix sorts first; ci folds ASCII case first 39 fn cmp a view uchar * b view uchar * ci bool to int 40 n = len a 41 if lt len b n 42 n = len b 43 end 44 for i ulong n 45 x = get a i 46 y = get b i 47 if and ci and ge x 65 le x 90 48 x = add x 32 49 end 50 if and ci and ge y 65 le y 90 51 y = add y 32 52 end 53 if lt x y 54 ret -1 55 end 56 if gt x y 57 ret 1 58 end 59 end 60 if lt len a len b 61 ret -1 62 end 63 if gt len a len b 64 ret 1 65 end 66 ret 0 67 end 68 fn show a view uchar * b view uchar * to void 69 c = cmp a b false 70 emit a 71 emit sp 72 emit b 73 emit teq 74 emitb eq c 0 75 emit tlt 76 emitb lt c 0 77 emit tgt 78 emitb gt c 0 79 emit tci 80 emitb eq cmp a b true 0 81 emit nl 82 end 83 fn main to int 84 show a1 b1 85 show a2 b2 86 show a3 b3 87 show b3 a3 88 ret 0 89 end 90 91 {{out}} 92

93 alpha beta eq=no lt=yes gt=no equal-ignoring-case=no

94 Hello hello eq=no lt=yes gt=no equal-ignoring-case=yes

95 abc abcd eq=no lt=yes gt=no equal-ignoring-case=no

96 abcd abc eq=no lt=no gt=yes equal-ignoring-case=no

97