Re: Recognize multiple outputs
- To: mathgroup at smc.vnet.net
- Subject: [mg118063] Re: Recognize multiple outputs
- From: ADL <alberto.dilullo at tiscali.it>
- Date: Mon, 11 Apr 2011 07:06:01 -0400 (EDT)
- References: <inpesa$8t8$1@smc.vnet.net> <inqkvf$e95$1@smc.vnet.net>
On 10 Apr, 00:01, Helen Read <read... at gmail.com> wrote: > On 4/9/2011 7:11 AM, mail... at gmail.com wrote: > > > Is it possible to show the name of the variables in the output cell? > > For example, currently I have > > [In1] a=10^2 > > [Out1] 100 > > > I want it to be > > [Out1] a=100 > > > The reason for this is when we have multiple lines of calculation in > > an input cell, > > sometimes it is hard to recognize which number is which, > > especially when the input cell has several pages and the calculations > > are scattered in the cell. > > Use Row to mix strings with expressions. > > a = 10^2; > Print[Row[{"a = ", a}]]; > g[x_] := x^3; > Print[Row[{"g(x) = ", g[x]}]]; > Print[Row[{"g'(x) = ", g'[x]}]]; > Print[Row[{"g'(a) = ", g'[a]}]]; > > -- > Helen Read > University of Vermont Another possibility is this: ClearAll[xPrint]; Attributes[xPrint]={HoldAll,Listable}; xPrint[x_]:=(Print[HoldForm[x]," =",Tab,x]; x); xPrint[x__]:=sPrint/@Unevaluated[x]; (* a ha no value *) xPrint[a]; a = a a=100 xPrint[a]; a = 100 ADL