1
$\begingroup$

Imagine I want to track the progress of constructing a complex Table or Do object by temporarily printing the iteration number. For example, if I do

Table[PrintTemporary[i];, {i, 20}]

I get

enter image description here

which is almost what I want, but I would rather have each print vanish at each step and get replaced by the following one so that I don't produce this huge list. Any ideas?

$\endgroup$
1
  • 2
    $\begingroup$ Monitor[Table[Pause[0.1], {i, 0, 1, 1/100}], ProgressIndicator[i]] or Monitor[Table[Pause[0.1], {i, 0, 100}], i] $\endgroup$ Commented Mar 30, 2022 at 14:39

1 Answer 1

8
$\begingroup$
Monitor[Table[Pause[0.1], {i, 0, 100}], i]
$\endgroup$
2
  • $\begingroup$ I've been using PrintTemporary[Dynamic[i]];Table[Pause[0.1], {i, 0, 100}] but this is nicer. $\endgroup$ Commented Mar 30, 2022 at 16:14
  • $\begingroup$ @ChrisK I think it's pretty much the same, but Monitor is more integrated and a bit more careful with localizing the variables. Maybe someone who knows more about variable scoping can give more information on this point. $\endgroup$ Commented Mar 30, 2022 at 17:08

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.