MathGroup Archive 2009

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

Search the Archive

Re: Re: Show doesn't work inside Do loop ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102045] Re: [mg102013] Re: Show doesn't work inside Do loop ?
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Mon, 27 Jul 2009 05:57:12 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <32390795.1248259308283.JavaMail.root@n11> <h4951e$q2e$1@smc.vnet.net> <21621663.1248432817472.JavaMail.root@n11> <h4eeul$spv$1@smc.vnet.net> <200907260756.DAA19062@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

I find nothing whatsoever that is not "consistent" in the behavior of Do 
with respect to a sequence of separate evaluations.

And no, I do not think it would be "reasonable" or "sensible" that Do 
produces output at each step of the loop.  The behavior of Do in this 
regard is the same as that of While and For. And the rationale is surely 
the same for all 3 functions: you simply do the iteration and specify 
explicitly (manually) what, if anything, you want to be returned or 
printed, even when the loop has been completed.  In fact, I would find 
it quite an annoyance were Do or While or For produced intermediate, or 
any, output without my explicitly asking for it.

AES wrote:
> In article <h4eeul$spv$1 at smc.vnet.net>,
>  "David Park" <djmpark at comcast.net> wrote:  (emphasis added)
> 
>> _On the other hand, Show does not generally generate a cell._ 
>>
>> Of course, it is easier to just apply Print to the Show or Plot statements.
>> So it is possible to make Show generate output cells, but it _normally_
>> doesn't do so. It normally only generates expressions, which because of its
>> special behavior a Do statement does not display.
> 
> 1)  Re your statements above: executing a single Input cell containing 
> just
> 
>    Show[ Graphics[ Circle[ {0, 0}, 1] ] ]
> 
> certainly generates an Output cell containing what looks like a 
> "graphic" or "plot" to me.
> 
> Is executing a cell containing a simple expression somehow an "abnormal" 
> process or action?
> 
> 2)  On a more general note:  Suppose you have an expression which 
> contains an explicit symbol x , such that if you execute three 
> consecutive cells containing
> 
>    x=1; expr
>    x=2; expr
>    x=3; expr
> 
> or maybe
> 
>    expr/.x->1
>    expr/.x->2
>    expr/.x->3
> 
> you get three output cells containing three successive instances of expr 
> (whatever that is) -- or appropriate error messages if executing expr 
> one of those times has some side effect that messes up a subsequent 
> execution.
> 
> Would it not be reasonable to expect a cell containing
> 
>    Do[ expr, {x,1,3} ]
> 
> to do _exactly_ the same thing?
> 
> In other words, would it not be reasonable -- consistent -- sensible -- 
> helpful -- the most useful -- to expect Do[ ] to be simply a "wrapper" 
> that functioned in exactly that manner?
> 
> I appreciate that Mathematica's Do[] apparently doesn't function that 
> way -- or functions that way sometimes, based on mysterious criteria, 
> but not other times; and suggest that this is not helpful or useful or 
> consistent behavior for many users.  
> 
> Are there any fundamental reasons why a DoConsistently[ ] command could 
> not be defined, such that DoConsistently[ expr, iterator ]  would 
> repeatedly put expr into a cell with each iterator instance applied to 
> it, and churn out the sequential outputs?  That, it seems to me, is what 
> many users would want and expect.
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: Re: Re: Re: Re: Thoughts on a Wolfram|Alpha
  • Next by Date: The audience for Mathematica (Was: Re: Show doesn't work inside Do loop ?)
  • Previous by thread: Re: Show doesn't work inside Do loop ?
  • Next by thread: Re: Re: Show doesn't work inside Do loop ?