Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

levenshtein package

Overview

Package levenshtein ports the classic Levenshtein edit-distance algorithm (as found in Go libraries like agext/levenshtein) to a gno.land realm.

The core is the textbook dynamic-programming matrix: the minimum number of single-character insertions, deletions, or substitutions to turn string a into string b. It is fully rune-aware and pure (deterministic), so it runs happily on-chain.

Function

Distance

func Distance(a, b string) int

Distance returns the Levenshtein edit distance between a and b.

It counts single-rune insertions, deletions, and substitutions and works on runes (not bytes), so multi-byte UTF-8 input is handled correctly. The classic two-row DP is used, so memory is O(min(len)) and time is O(len(a)*len(b)).

Params

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/levenshtein.Distance(,)"

Result