Hi folks - I was trying the example posted below, and I discovered a slight snag - unchecked-* methods don't exist for doubles or floats! (and if you call (unchecked-multiply 1.2 3.4) you get "No matching method found"... which caused some confusion :) )
Is this something that might change in the future? Or would it be easy for a clojure newbie to implement them himself? :-} - Korny On Sat, Jan 24, 2009 at 2:48 AM, Zak Wilson <zak.wil...@gmail.com> wrote: > > If a speed boost is what you're going for, you can probably get one > from type coercion and (if you're not worried about overflow) > unchecked-math. As an example: > > (defn step [x0, y0, xn, yn] > (let [dx0 (double x0) > dy0 (double y0) > dxn (double xn) > dyn (double yn) > xm (unchecked-add (unchecked-subtract (unchecked-multiply xn > xn)(unchecked-multiply yn yn)) x0) > ym (unchecked-add (unchecked-multiply 2 xn yn) y0)] > [xm ym])) > > It's not pretty, I know, but you could assign shorter names for the > unchecked-math functions if you end up using them heavily. > > > -- Kornelis Sietsma korny at my surname dot com kornys on gmail, twitter, facebook, etc. "Every jumbled pile of person has a thinking part that wonders what the part that isn't thinking isn't thinking of" --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---