Skip to content

Instantly share code, notes, and snippets.

@francoisdevlin
Created February 12, 2010 16:59
Show Gist options
  • Save francoisdevlin/302748 to your computer and use it in GitHub Desktop.
Save francoisdevlin/302748 to your computer and use it in GitHub Desktop.
(defn -sqr [a b] (let [d (- a b)] (* d d)))
(defn -dist [a b] (Math/sqrt (-sqr a b)))
(defn converge
([epsilon coll] (converge epsilon -dist coll))
([epsilon distance coll]
(ffirst
(drop-while
(fn [[a b] & more] (< epsilon (distance a b)))
(partition 2 1 coll)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment