Jump to content

Levenshtein distance/Alignment: Difference between revisions

Line 160:
⟳ ic:(1 |..| source.count) ¦ l_distance [ic, 1] := ic - 1 ⟲
⟳ ij:(1 |..| target.count) ¦ l_distance [1, ij] := ij - 1 ⟲
⟳ ic:(1 |..| source.count) ¦
⟳ jc:(1 |..| target.count) ¦
if ic > 1 and jc > 1 then
Line 178:
</lang>{{out}}
Result = 8
 
The ⟳ ¦ ⟲ represents the "symbolic form" of an Eiffel across loop. In the case above, we use two ⟳ (loops) to set the `l_distance' array elements, and then two nested ⟳ (loops) to walk the distance computation.
 
Also—the `ic' is this programmers shorthand for ITERATION_CURSOR. Therefore, in the nested loops, the `ic' is the iteration cursor following `i' and the `ij' is following `j' as indexes on the source, target, and l_distance.
 
=={{header|Go}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.