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-unique-characters/determine-if-a-string-has-all-unique-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-unique-characters / determine-if-a-string-has-all-unique-characters.om` 80 lines ยท 1511 bytes Raw Blame History 1 note Rosetta Code task "Determine if a string has all unique characters": https://rosettacode.org/wiki/Determine_if_a_string_has_all_unique_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 tuni ": all unique\n" 9 text tdup ": duplicate '" 10 text tat "' at " 11 text tand " and " 12 text u0 "." 13 text u1 "abcABC" 14 text u2 "XYZ ZYX" 15 text u3 "1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ" 16 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 17 fn emit a view uchar * to void 18 o = ulong 0 19 while lt o len a bound 4096 20 k = write 1 a o sub len a o 21 if le k 0 22 exit 1 23 end 24 o = add o ulong k 25 end 26 end 27 note emitu writes n in decimal; 20 digits hold every ulong 28 fn emitu n ulong to void 29 d = new uchar 20 0 30 i = ulong 20 31 v = n 32 while true bound 20 33 i = sub i 1 34 put d i uchar add rem v 10 48 35 v = div v 10 36 if eq v 0 37 break 38 end 39 end 40 emit part d i sub 20 i 41 end 42 note emitc writes one byte 43 fn emitc c uchar to void 44 b = new uchar 1 0 45 put b 0 c 46 emit b 47 end 48 note the first byte (smallest i) that occurs again later, with the place j of its next occurrence 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 for j ulong sub sub len a i 1 57 k = add add i j 1 58 if eq get a i get a k 59 emit tdup 60 emitc get a i 61 emit tat 62 emitu i 63 emit tand 64 emitu k 65 emit nl 66 ret 67 end 68 end 69 end 70 emit tuni 71 end 72 fn main to int 73 note the empty string, as a slice of length 0 74 show part u0 0 0 75 show u0 76 show u1 77 show u2 78 show u3 79 ret 0 80 end