On Mon, Apr 7, 2014 at 5:26 PM, Yehonathan Sharvit <[email protected]> wrote:
> (defn my-sum[a]
> (def res 0)
> (doseq [x a]
> (set! res (+ res x )))
> res)
>
def's are always top-level. Do not put def's in def's like this.
(defn my-sum [a]
(loop [i 0 sum 0]
(if (< i (alength a))
(recur (inc i) (+ sum (aget a i))
sum)))
Should give similar performance to the version you wrote in JavaScript.
David
--
Note that posts from new members are moderated - please be patient with your
first post.
---
You received this message because you are subscribed to the Google Groups
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.