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-mv/blob/main/si/rosetta/tasks/determine-if-a-string-has-all-the-same-characters/determine-if-a-string-has-all-the-same-characters.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / si / rosetta / tasks / determine-if-a-string-has-all-the-same-characters / determine-if-a-string-has-all-the-same-characters.om` 77 lines ยท 1354 bytes Raw Blame History 1 note Rosetta Code task "Determine if a string has all the same characters": https://rosettacode.org/wiki/Determine_if_a_string_has_all_the_same_characters 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 text lq "<<<" 6 text rq ">>>" 7 text tlen " length " 8 text tsame ": all the same\n" 9 text tdiff ": first different '" 10 text tat "' at " 11 text u0 " " 12 text u1 "2" 13 text u2 "333" 14 text u3 ".55" 15 text u4 "tttTTT" 16 text u5 "4444 444k" 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 show a view uchar * to void 50 emit lq 51 emit a 52 emit rq 53 emit tlen 54 emitu len a 55 for i ulong len a 56 if ne get a i get a 0 57 emit tdiff 58 emitc get a i 59 emit tat 60 emitu i 61 emit nl 62 ret 63 end 64 end 65 emit tsame 66 end 67 fn main to int 68 note the empty string, as a slice of length 0 69 show part u0 0 0 70 show u0 71 show u1 72 show u2 73 show u3 74 show u4 75 show u5 76 ret 0 77 end