5
$\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$
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, privacy policy and cookie policy

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