Re: Print in a loop
- To: mathgroup at smc.vnet.net
- Subject: [mg103217] Re: Print in a loop
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Thu, 10 Sep 2009 07:25:11 -0400 (EDT)
- References: <h87pef$5fv$1@smc.vnet.net>
On 2009.09.09. 10:36, Luiz Melo wrote:
> The loop
>
> Do[Print[i],{i,3}]
>
> results in:
>
> 1
> then
> 1
> 2
> then
> 1
> 2
> 3
>
> How can we obtain:
> 1
> then
> 2
> then
> 3
>
>
This isn't exactly an answer to your question, but perhaps you're
looking for Monitor rather than Print?
Monitor[Do[Pause[0.5], {i, 3}], i]
This kind of thing is probably more easily achieved using Dynamic
constructs than explicit use of Print[]. You can also try
Clear[i]
Dynamic[i]
Do[Pause[.5], {i,3}]
and watch the output cell produced by Dynamic.