Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7992 > unrolled thread

Re: Question about function

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-01-19 10:07 +0000
Last post2012-01-19 10:07 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Question about function Bob Hanlon <hanlonr357@gmail.com> - 2012-01-19 10:07 +0000

#7992 — Re: Question about function

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-01-19 10:07 +0000
SubjectRe: Question about function
Message-ID<jf8q1t$3fd$1@smc.vnet.net>
Use SetAttributes to set attributes; and to make use of the attribute
Listable, put the arguments into a list.

ClearAll[xPrint]
SetAttributes[xPrint, {HoldAll, Listable}];
xPrint[x_] := (Print[HoldForm[x], " =", Tab, x]);
a = 5;
b = 6;

xPrint[a];

a =	5

xPrint[{a, b}];

a =	5

b =	6


Bob Hanlon

On Wed, Jan 18, 2012 at 6:01 AM, oversky <mailcwc@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[]?
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web