MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Monitor bug or feature

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84107] Re: [mg84095] Monitor bug or feature
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Mon, 10 Dec 2007 20:36:48 -0500 (EST)
  • References: <200712100936.EAA16329@smc.vnet.net>

Mark Fisher wrote:

>Hi all,
>
>Monitor[Table[Pause[.1]; i, {i, 10}], i]
>
>works as I expected, but
>
>Table[Pause[.1]; i, {i, 10}] // Monitor[#, i] &
>
>does not: It does not produce any "monitoring".
>
>Are there other examples where
>
>f[x, a]
>
>and
>
>f[#,a]&[x]
>
>produce different "effects". (Clearly the Heads of the expressions are
>different.)
>  
>
You are getting an evaluation leak. Monitor has the attribute HoldAll, 
and in the first example the Table expression is not evaluated until 
Monitor is ready. In the second example, the Table expression is 
evaluated too early. That is, the second example is really:

Monitor[{1,2,3,4,5,6,7,8,9,10}, i]

and of course, no monitoring will occur. In general,

f[#,a]&[x]

will evaluate x before it is inserted into f. To avoid this, you can use 
Function with the optional third argument:

Table[Pause[.1]; i, {i, 10}] // Function[x, Monitor[x, i], HoldAll]

Carl Woll
Wolfram Research

>I'm guessing my surprise regarding this feature of Monitor reflects
>the fact that I really haven't made any attempt to understand Dynamic
>etc.
>
>--Mark
>  
>



  • Prev by Date: Re: Inset problems & Export
  • Next by Date: Re: Precedence of Infix Operator
  • Previous by thread: Monitor bug or feature
  • Next by thread: Re: Monitor bug or feature