On Mon, Feb 22, 2010 at 12:18 AM, Johnny Kwan <johnny.c.k...@gmail.com> wrote:
> I'm really new to Clojure, but I'm under the impression that reduce would be 
> better than apply, since I assume that apply would reify the entire sequence 
> at once, whereas reduce would consume the sequence one by one.

I was going by this: "For certain functions, such as addition, they
are the same, but that is
because the addition function (+) itself 'reduces' its arguments."
http://osdir.com/ml/java.clojure.user/2008-07/msg00237.htm

The thread is somewhat older, but looking at the source for + it seems
like this is still valid:

user=> (source +)
(defn +
  "Returns the sum of nums. (+) returns 0."
  {:inline (fn [x y] `(. clojure.lang.Numbers (add ~x ~y)))
   :inline-arities #{2}}
  ([] 0)
  ([x] (cast Number x))
  ([x y] (. clojure.lang.Numbers (add x y)))
  ([x y & more]
   (reduce + (+ x y) more)))

Michael

-- 
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

Reply via email to