R/progress_bar_foreach.R

Defines functions progress_bar_foreach

progress_bar_foreach <- function(iterator, fun = NULL, clear = TRUE){
  # credits to:
  # https://gist.github.com/kvasilopoulos/d49499ea854541924a8a4cc43a77fed0
  pb <- progress_bar$new(total = iterator, show_after = 0, clear = clear)
  pb$tick(0)
  
  count <- 1
  function(...) {
    count <<- count + length(list(...)) - 1
    pb$update(count/iterator)
    fun(...)
    
  }
}
bblonder/hypervolume documentation built on Jan. 21, 2025, 3:09 p.m.