areduce

added
1.0

ns
clojure.core

type
macro

(areduce a idx ret init expr)

Reduces an expression across an array a, using an index named idx,
and return value named ret, initialized to init, setting ret to the 
evaluation of expr at each step, returning ret.

                ;; This should be about as quick as summing up a array of floats in java.

user=> (defn asum [^floats xs]
         (areduce xs i ret (float 0)
                  (+ ret (aget xs i))))

user=> (asum (float-array [1 2 3]))
6.0