Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Display[ ] renewed?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90414] Re: Display[ ] renewed?
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Tue, 8 Jul 2008 07:49:20 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <g4v303$if1$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

something like

SetAttributes[DoPrint, HoldAll]

DoPrint[body_, {i_, i1_, i2_}] := Module[{split},
   split = Hold[body] /. CompoundExpression -> List;
   split =
    Flatten[split //. {Hold[{a_, b___}] :> {Hold[a], Hold[b]} ,
       Hold[a_, b__] :> { Hold[a], Hold[b]}}];
   split = split /. Hold[a_] :> Hold[Print[a]];
   Do[
    ReleaseHold[split /. i -> ii], {ii, i1, i2}
    ]
   ]

and

DoPrint[
  Sin[x]; q; y = i^2, {i, 1, 3}]

Regards
   Jens

AES wrote:
> I'd like to ask what if any ways are available in addition to Print[] to 
> make a sequence of tested and functioning notebook Input cells produce 
> exactly the same sequence of displayed Output cells when these Input 
> cells are merged and wrapped into a Do[] loop?
> 
> I'm supposing the straightforward answer is, ''Make the last expression 
> in each of these individual Input cells be a 'Print[---];' statement 
> that produces the desired output''; but I'm asking if there are other 
> solutions?
> 
> [If you want a more specific query, suppose I've coded and tested a set 
> of compound expressions -- let's call them cell1, cell2, etc., since 
> each one of them is located by itself in a separate notebook cell.  Each 
> such cell, when evaluated by itself, produces and displays in an output 
> cell a graphic, or a Table, or some other visible output that I'm happy 
> with.  These cells may depend on a common global variable and some fixed 
> global parameters, but are independent enough of each other that if they 
> are arranged in any order in a notebook and executed, each cell produces 
> the same output as in any other sequence.  What further coding is 
> required to merge these Input cells into a single compound expression 
> and wrap this expression in a Do[ ] loop so that each execution of the 
> loop produces the same set of *separate* Output cells as if the initial 
> Input cells.]
> 


  • Prev by Date: Re: ReplaceAll
  • Next by Date: Re: running multiple mathkernel's
  • Previous by thread: Display[ ] renewed?
  • Next by thread: Re: Display[ ] renewed?