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/levenshtein-distance.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 / levenshtein-distance.wiki` 90 lines ยท 1600 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 "kitten" 9 text b1 "sitting" 10 text a2 "rosettacode" 11 text b2 "raisethysword" 12 text a3 "saturday" 13 text b3 "sunday" 14 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 15 fn emit a view uchar * to void 16 o = ulong 0 17 while lt o len a bound 4096 18 k = write 1 a o sub len a o 19 if le k 0 20 exit 1 21 end 22 o = add o ulong k 23 end 24 end 25 note emitu writes n in decimal; 20 digits hold every ulong 26 fn emitu n ulong to void 27 d = new uchar 20 0 28 i = ulong 20 29 v = n 30 while true bound 20 31 i = sub i 1 32 put d i uchar add rem v 10 48 33 v = div v 10 34 if eq v 0 35 break 36 end 37 end 38 emit part d i sub 20 i 39 end 40 note two-row dynamic programme; strings up to 63 bytes (longer traps 3) 41 fn lev a view uchar * b view uchar * to ulong 42 p = new ulong 64 0 43 q = new ulong 64 0 44 for j ulong add len b 1 45 put p j j 46 end 47 for i ulong len a 48 put q 0 add i 1 49 for j ulong len b 50 c = add get p j 1 51 if eq get a i get b j 52 c = get p j 53 end 54 x = add get p add j 1 1 55 if lt x c 56 c = x 57 end 58 x = add get q j 1 59 if lt x c 60 c = x 61 end 62 put q add j 1 c 63 end 64 for j ulong add len b 1 65 put p j get q j 66 end 67 end 68 ret get p len b 69 end 70 fn show a view uchar * b view uchar * to void 71 emit a 72 emit sp 73 emit b 74 emit sp 75 emitu lev a b 76 emit nl 77 end 78 fn main to int 79 show a1 b1 80 show a2 b2 81 show a3 b3 82 ret 0 83 end 84 85 {{out}} 86

87 kitten sitting 3

88 rosettacode raisethysword 8

89 saturday sunday 3

90