Skip to content

Instantly share code, notes, and snippets.

View ck's full-sized avatar
💭
I may be slow to respond.

ck ck

💭
I may be slow to respond.
  • United States
  • 13:55 (UTC -04:00)
View GitHub Profile
@ck
ck / levenshtein.clj
Created May 7, 2011 18:33 — forked from vishnuvyas/levenshtein.clj
A purely functional implementation of levenshtein distance in clojure
(ns levenshtein
^{:doc "A purely functional implementation of the levenshtien distance in clojure"})
(defn- compute-next-row
"computes the next row using the prev-row current-element and the other seq"
[prev-row current-element other-seq pred]
(reduce
(fn [row [diagonal above other-element]]
(let [update-val
(if (pred other-element current-element)
;; stolen from http://cemerick.com/2010/08/02/defrecord-slot-defaults/
(defmacro defrecord+defaults
"Defines a new record, along with a new-RecordName factory function that
returns an instance of the record initialized with the default values
provided as part of the record's slot declarations. e.g.
(defrecord+ Foo [a 5 b \"hi\"])
(new-Foo)
=> #user.Foo{:a 5, :b \"hi\"}"
[name slots & etc]