levenshtein-fuzzy-match-pure-kmp
Installation
SKILL.md
Edit distance and candidate selection, in shared code
Edit distance is one nested loop and two integer arrays. Writing it out is cheaper than finding a
multiplatform library for it, and the result compiles into shared code with no expect/actual:
// adapted
fun levenshtein(lhs: CharSequence, rhs: CharSequence): Int {
var cost = IntArray(lhs.length + 1) { it } // row for rhs-prefix of length 0
var newCost = IntArray(lhs.length + 1) { 0 }