Implementing Binary Search with Clojure

I was trying to implement a simple binary search using a purely functional approach, and after much hacking, googling and wikibooking, came up with this in Clojure.

(defn binarysearch ( \ (binarysearch lst 0 (dec (count lst)) n)) ( \ (if (> lb ub) -1 ; this is the case where no element is found (let [mid (quot (+ lb ub) 2) mth (nth lst mid)] (cond ; mid > n, so search lower (> mth n) (recur lst lb (dec mid) n) ; mid

--

If you have any questions or thoughts, don't hesitate to reach out. You can find me as @viksit on Twitter.