Skip to content

Commit

Permalink
Update Levenshtein distance example to use Nat in place of Int.
Browse files Browse the repository at this point in the history
  • Loading branch information
axch committed May 31, 2022
1 parent 10d4346 commit 5cbbdc5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions examples/levenshtein-distance.dx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def levenshtein_table
{n m a}
[Eq a]
(xs: n=>a) (ys: m=>a)
: (Post n => Post m => Int) =
yield_state (for _ _. -1) \tab.
: (Post n => Post m => Nat) =
yield_state (for _ _. 0) \tab.
for i:(Post n). tab!i!first_ix := ordinal i
for j:(Post m). tab!first_ix!j := ordinal j
for i:n j:m.
Expand All @@ -48,7 +48,7 @@ levenshtein_table ['k', 'i', 't', 't', 'e', 'n'] ['s', 'i', 't', 't', 'i', 'n',

'The actual distance is of course just the last element of the table.

def levenshtein {n m a} [Eq a] (xs: n=>a) (ys: m=>a) : Int =
def levenshtein {n m a} [Eq a] (xs: n=>a) (ys: m=>a) : Nat =
(levenshtein_table xs ys).last_ix.last_ix

%time
Expand Down

0 comments on commit 5cbbdc5

Please sign in to comment.