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
### | |
Web Toolkit v0.4 (by M@ McCray) | |
http://gist.github.com/515035 | |
NOTE: This is meant to be used as a Cakefile (Coffee's RAKE equivalent). | |
### | |
puts = require("util").puts |
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 bsrch [needle haystack] | |
(loop [low (int 0) high (count haystack) mid (quot (count haystack) 2)] | |
(if (= (haystack mid) needle) | |
mid | |
(if (= high low) | |
-1 | |
(if (> needle (haystack mid)) | |
(recur (int (inc mid)) high (quot (+ mid high) 2)) | |
(recur low (int (dec mid)) (quot (+ low mid) 2)) | |
))) |
NewerOlder