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/determine-if-a-string-is-squeezable.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 / determine-if-a-string-is-squeezable.wiki` 108 lines ยท 3071 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 lq "<<<" 8 text rq ">>>" 9 text tlen " length " 10 text tch "squeeze '" 11 text tq "'\n" 12 text c0 "\"If I were two-faced, would I be wearing this one?\" --- Abraham Lincoln " 13 text c1 "..`1111111111111111111111111111111111111111111111111111111111111117777888`" 14 text c2 "I never give 'em hell, I just tell the truth, and they think it's hell. " 15 text c3 " --- Harry S Truman " 16 text chars "-7. -r" 17 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 18 fn emit a view uchar * to void 19 o = ulong 0 20 while lt o len a bound 4096 21 k = write 1 a o sub len a o 22 if le k 0 23 exit 1 24 end 25 o = add o ulong k 26 end 27 end 28 note emitu writes n in decimal; 20 digits hold every ulong 29 fn emitu n ulong to void 30 d = new uchar 20 0 31 i = ulong 20 32 v = n 33 while true bound 20 34 i = sub i 1 35 put d i uchar add rem v 10 48 36 v = div v 10 37 if eq v 0 38 break 39 end 40 end 41 emit part d i sub 20 i 42 end 43 note emitc writes one byte 44 fn emitc c uchar to void 45 b = new uchar 1 0 46 put b 0 c 47 emit b 48 end 49 fn line a view uchar * to void 50 emit lq 51 emit a 52 emit rq 53 emit tlen 54 emitu len a 55 emit nl 56 end 57 note squeeze drops a byte equal to ch when the byte before it is also ch 58 fn squeeze a view uchar * ch uchar to void 59 o = new uchar 256 0 60 n = ulong 0 61 for i ulong len a 62 c = get a i 63 k = true 64 if and gt i 0 eq c ch 65 k = ne get a sub i 1 ch 66 end 67 if k 68 put o n c 69 n = add n 1 70 end 71 end 72 emit tch 73 emitc ch 74 emit tq 75 line a 76 line part o 0 n 77 end 78 fn main to int 79 squeeze c1 get chars 0 80 squeeze c1 get chars 1 81 squeeze c2 get chars 2 82 squeeze c3 get chars 3 83 squeeze c3 get chars 4 84 squeeze c3 get chars 5 85 ret 0 86 end 87 88 {{out}} 89

90 squeeze '-'

91 <<<..`1111111111111111111111111111111111111111111111111111111111111117777888`>>> length 72

92 <<<..`1111111111111111111111111111111111111111111111111111111111111117777888`>>> length 72

93 squeeze '7'

94 <<<..`1111111111111111111111111111111111111111111111111111111111111117777888`>>> length 72

95 <<<..`1111111111111111111111111111111111111111111111111111111111111117888`>>> length 69

96 squeeze '.'

97 <<<I never give 'em hell, I just tell the truth, and they think it's hell. >>> length 72

98 <<<I never give 'em hell, I just tell the truth, and they think it's hell. >>> length 72

99 squeeze ' '

100 <<< --- Harry S Truman >>> length 72

101 <<< --- Harry S Truman >>> length 20

102 squeeze '-'

103 <<< --- Harry S Truman >>> length 72

104 <<< - Harry S Truman >>> length 70

105 squeeze 'r'

106 <<< --- Harry S Truman >>> length 72

107 <<< --- Hary S Truman >>> length 71

108