MCPcopy Index your code
hub / github.com/clojure/clojure / reduce

Method reduce

src/jvm/clojure/lang/PersistentVector.java:394–411  ·  view source on GitHub ↗
(IFn f)

Source from the content-addressed store, hash-verified

392public Spliterator spliterator(){return rangedSpliterator(0,count());}
393
394public Object reduce(IFn f){
395 Object init;
396 if (cnt > 0)
397 init = arrayFor(0)[0];
398 else
399 return f.invoke();
400 int step = 0;
401 for(int i=0;i<cnt;i+=step){
402 Object[] array = arrayFor(i);
403 for(int j = (i==0)?1:0;j<array.length;++j){
404 init = f.invoke(init,array[j]);
405 if(RT.isReduced(init))
406 return ((IDeref)init).deref();
407 }
408 step = array.length;
409 }
410 return init;
411}
412
413public Object reduce(IFn f, Object init){
414 int step = 0;

Callers

nothing calls this directly

Calls 4

arrayForMethod · 0.95
isReducedMethod · 0.95
invokeMethod · 0.65
derefMethod · 0.65

Tested by

no test coverage detected