pv_kv_reduce function

dynamic pv_kv_reduce(
  1. dynamic pv$1,
  2. dynamic f$1,
  3. dynamic from$1,
  4. dynamic to$1,
  5. dynamic init$1,
)

Implementation

dc.dynamic pv_kv_reduce(dc.dynamic pv$1, dc.dynamic f$1, dc.dynamic from$1, dc.dynamic to$1, dc.dynamic init$1, ){
if(((from$1 as dc.int)<(to$1 as dc.int))){
final dc.int tail_off$1=(((pv$1 as lcoc_core.PersistentVector).cnt-1)&(~31));
final lcoc_core.VectorNode root$1=(pv$1 as lcoc_core.PersistentVector).root;
final dc.int shift$1=(pv$1 as lcoc_core.PersistentVector).shift;
final dc.List tail$1=(pv$1 as lcoc_core.PersistentVector).tail;
dc.dynamic acc$1=init$1;
dc.int i$1=(from$1 as dc.int);
dc.dynamic arr$1;
if((0==tail_off$1)){
arr$1=tail$1;
}else{
arr$1=lcoc_core.unchecked_array_for(root$1, shift$1, i$1, );
}
do {
if((i$1<(to$1 as dc.int))){
final dc.dynamic arg$1=((arr$1 as dc.List)[(i$1&31)]);
late final dc.dynamic val$1;
if((f$1 is dc.Function)){
val$1=(f$1 as dc.Function)(acc$1, i$1, arg$1, );
}else if((f$1 is lcoc_core.IFn$iface)){
val$1=((f$1 as lcoc_core.IFn$iface).$_invoke$3(acc$1, i$1, arg$1, ));
}else{
val$1=(lcoc_core.IFn.extensions(f$1, ).$_invoke$3(f$1, acc$1, i$1, arg$1, ));
}
final dc.int i$PRIME_$1=(1+i$1);
if(lcoc_core.reduced$QMARK_(val$1, )){
return lcoc_core.deref(val$1, );
}
acc$1=val$1;
i$1=i$PRIME_$1;
if((0<(i$PRIME_$1&31))){
arr$1=arr$1;
}else if((tail_off$1==i$PRIME_$1)){
arr$1=tail$1;
}else if((i$PRIME_$1<(to$1 as dc.int))){
arr$1=lcoc_core.unchecked_array_for(root$1, shift$1, i$PRIME_$1, );
}else{
arr$1=null;
}
continue;
}
return acc$1;
} while(true);
}
return init$1;
}