6
$\begingroup$

If we have a procedural construct like a Do loop or Table, it is straightforward to make a progress bar to indicate the percent completion of the task. For example:

f[k_] := RandomInteger[{-k, k}, 1000000];
ProgressIndicator[Dynamic[k/100]]
Do[f[k], {k, Range[100]}]

Replacing Do by Table works as well. But I have grown fond of the "functional style" using Map:

f[#]& /@ Range[100]

Is there a way to make a progress indicator that works with this style of iteration?

$\endgroup$
1
  • $\begingroup$ related $\endgroup$
    – Kuba
    Mar 28, 2015 at 15:36

1 Answer 1

4
$\begingroup$

You can include an iterator along with the function in the mapping:

k = 0; (++k; f[#]) & /@ Range[100];
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.