MathGroup Archive 2012

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

Search the Archive

Re: Question about function


Attributes[xPrint] = {HoldAll, Listable};
xPrint[x_] := (Print[HoldForm[x], " =", Tab, x]);
xPrint[x_, y__] := (xPrint[x]; xPrint[y])

a = 5;
b = 6;
xPrint[a, b, Pi, a + b]

a =	5

b =	6

\[Pi] =	\[Pi]

a+b =	11

Bobby

On Wed, 18 Jan 2012 05:01:56 -0600, oversky <mailcwc at gmail.com> wrote:

> I define the following function:
>
> xPrint[x_]:=(Print[HoldForm[x]," =",Tab,x]);
> Attributes[xPrint]={HoldAll,Listable};
> a=5;
> xPrint[a]
>
> -> a =        5
>
> I want to modify this code such that it can handle multiple arguments.
> For example,
>
> a=5;
> b=6;
> xPrint[a,b]
>
> -> a =      5
> -> b =      6
>
> How do I get the argument one by one and feed it into Print[]?
>
>
>


-- 
DrMajorBob at yahoo.com



  • Prev by Date: Re: Question about function
  • Next by Date: missing Tooltip for ArrayPlot etc. - workaround
  • Previous by thread: Re: Question about function
  • Next by thread: Re: Question about function