Previous: , Up: levenshtein   [Index]


30.2 Type–coercing comparisons

Procedures levenshtein and levenshtein/predicate provide a convenient interface for comparing a combination of vectors, lists, and strings, the types of which might not be known until runtime.

Function: levenshtein/predicate a b pred

Calculate the Levenshtein Distance of two objects a and b, which are vectors, lists, or strings. a and b need not be of the same type. pred is the element equivalence predicate used.

(levenshtein/predicate '#(#\A #\B #\C #\D)
                       "aBXcD"
                       char-ci=?)
⇒ 1
Function: levenshtein a b

Calculate the Levenshtein Distance of a and b, in a similar manner as using levenshtein/predicate with equal? as the predicate.

(define g '#(#\g #\u #\m #\b #\o))

(levenshtein g "gambol")  ⇒ 2
(levenshtein g "dumbo")   ⇒ 1
(levenshtein g "umbrage") ⇒ 5