Coercing m to int somehow prevents h from being boxed: user=> (defn bin-search [v k c] (loop [l 0 h (dec (count v))] (if (> l h) false (let [m (int (quot (+ l h) 2)) m-v (v m)] (cond (> m-v k) (recur (inc m) h) (> k m-v) (recur l (dec m)) :else m))))) #'user/bin-search user=>
On May 26, 5:08 pm, Luc Prefontaine <lprefonta...@softaddicts.ca> wrote: > h gets boxed somehow from integer to something else when the recur is > executed. > > No idea where however. Look at this, it may help: > > http://groups.google.com/group/clojure/browse_thread/thread/e4574bbb0... > > On Fri, 27 May 2011 09:54:19 +1000 > > > > Andreas Kostler <andreas.koestler.le...@gmail.com> wrote: > > Hi guys, > > I'm kinda lost as to what's going on here...With clojure-1.2.0 > > > (defn bin-search [v k c] > > (loop [l 0 > > h (dec (count v))] > > (if (> l h) false > > (let [m (quot (+ l h) 2) > > m-v (v m)] > > (cond (> m-v k) (recur (inc m) h) > > (> k m-v) (recur l (dec m)) > > :else m))))) > > > This bombs out with: > > java.lang.IllegalArgumentException: recur arg for primitive local: h > > must be matching primitive > > > With 1.3.0-master-SNAPSHOT it works fine. Any ideas what I'm doing > > wrong? Andreas > > -- > Luc P. > > ================ > The rabid Muppet -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en