Skip to content

Instantly share code, notes, and snippets.

@jacoobes
Created June 22, 2024 04:14
Show Gist options
  • Save jacoobes/16b6a95274eb3cea9b52278732c051bf to your computer and use it in GitHub Desktop.
Save jacoobes/16b6a95274eb3cea9b52278732c051bf to your computer and use it in GitHub Desktop.
Levensthein Distance
(defn lev [a b]
(let [[hda & rsta] a cta (count a)
[hdb & rstb] b ctb (count b)]
(cond (zero? ctb) cta
(zero? cta) ctb
(= hda hdb) (lev rsta rstb)
:else (inc (min (lev rsta b) (lev a rstb) (lev rsta rstb))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment