Levenshtein distance: Difference between revisions
m
→{{header|RPL}}: typo
(added RPL) |
m (→{{header|RPL}}: typo) |
||
Line 5,658:
|}
"kitten" "sitting" <span style="color:blue">LEV</span>
"Summer" "Winter" <span style="color:blue">LEV</span>
"Levenshtein" "Levenshtein" <span style="color:blue">LEV</span>
{{out}}
<pre>
Line 5,670:
===Iterative implementation (Wagner-Fischer algorithm)===
index of arrays and strings start with 1 in RPL, so the main trick in translating the algorithm given by Wikipedia was to manage the offsets properly. The distance between "rosettacode" and "raisethysword" is within the reach of a
{{works with|HP|48}}
{| class="wikitable"
Line 5,697:
<span style="color:blue">LEV2</span> ''( "a" "b" → distance )''
declare int d[0..m, 0..n] and set each element in d to zero
for h from 1 to m: <span style="color:grey>
d[h, 0] := i <span style="color:grey>
for j from 1 to n:
d[0, j] := j
|