R/bisect_reduce.R

Defines functions bisect_reduce

bisect_reduce <- function(x, fun) {
  n <- length(x)
  if (n == 1) {
    return(x[[1]])
  }
  mid <- floor(n / 2)
  incl <- seq_len(mid)
  left <- bisect_reduce(x[incl], fun)
  right <- bisect_reduce(x[-incl], fun)
  fun(left, right)
}

Try the duckplyr package in your browser

Any scripts or data that you put into this service are public.

duckplyr documentation built on Nov. 5, 2025, 6:19 p.m.