Created
June 22, 2024 04:14
-
-
Save jacoobes/16b6a95274eb3cea9b52278732c051bf to your computer and use it in GitHub Desktop.
Levensthein Distance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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