-
-
Save rightfold/6ec5cb7c18c0050ba403 to your computer and use it in GitHub Desktop.
This file contains 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 bsearch [xs cmp] | |
(if (empty? xs) | |
nil | |
(let [[as bs] (split-at (quot (count xs) 2) xs) | |
res (cmp (first bs))] | |
(cond | |
(= res 0) (first bs) | |
(< res 0) (recur as cmp) | |
(> res 0) (recur bs cmp))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment