I wasn't able to find a Levensthein Distance function done in auto Sharing for anyone else that looks.[/code]
1)First I define list of testCode - Auto/Visual Lisp: [Select]02)I need help. Why the function "str_Levenshtein" have infinite-loop?
03)My son quite often goes to the stadium.Code: [Select]package main
func levenshtein(s, t string) int {
if s == "" { return len(t) }
if t == "" { return len(s) }
if s[0] == t[0] {
return levenshtein(s[1:], t[1:])
}
a := levenshtein(s[1:], t[1:])
b := levenshtein(s, t[1:])
c := levenshtein(s[1:], t)
if a > b { a = b }
if a > c { a = c }
return a + 1
}
func main() {
s1 := "After lunch, they go to bed."
s2 := "After lunch, they almost always go to bed."
fmt.Printf("distance between %s and %s: %d\n", s1, s2,
levenshtein(s1, s2))}