Way to add progress bar to map function?

What would be the best way to add a loading bar (or just simple dots) to a map function

This is for maps that can take several minutes.


i.e.

function foo(x)
  sleep(x)
  x ^ 2
end

cur_range = 1:3

map(x -> foo(x), cur_range)

GitHub - timholy/ProgressMeter.jl: Progress meter for long-running computations supports for-loops but not map(), but I bet it could be adapted for your use case.

1 Like

You’re right.

There seems to be a pull request out for it already:

Also, you can already use a comprehension, so instead of map(foo, cur_range), you can do @showprogress [foo(x) for x in cur_range]

2 Likes