On 9 July 2013 17:11, Alexander Gunnarson <alexandergunnar...@gmail.com> wrote:
> Final Solution
>
> (defn solveit-4 [t0 y0 h its]
>   (let [zero (long 0)]
>     (loop [t0 (double t0) y0 (double y0) h (double h) its (long its)]
>       (if (> its zero)
>         (let [t1 (+ t0 h)
>               y1 (+ y0 (* h (- t0 y0)))]
>           (recur t1 y1 h (dec its)))
>       [t0 y0 h its]))))

Functions of up to four arguments can take primitives directly:

(defn solveit [^double t0 ^double y0 ^double h ^long its] ...)

Also, the hinting of 0 with long should not be necessary, as it's
currently the default for an integer literal (without an N signifying
bigint at the end).

I'm not going to benchmark now, but the original version with hints
added in the parameter vector as above should perform just like
solveit-4.

Cheers,
Michał

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to