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


Groups > comp.soft-sys.math.mathematica > #7990

Re: Question about function

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!newsfeeds.sol.net!post2.nntp.sol.net!posts.news.twtelecom.net!nnrp2.twtelecom.net!not-for-mail
From "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Question about function
Date Thu, 19 Jan 2012 10:06:52 +0000 (UTC)
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <jf8pvs$3ea$1@smc.vnet.net> (permalink)
References <jf6917$gbm$1@smc.vnet.net>
Lines 39
NNTP-Posting-Date 19 Jan 2012 10:07:18 GMT
NNTP-Posting-Host 15176440.news.twtelecom.net
X-Trace DXC=235WT8<M9GWXl]7<OF\B7WC_A=>8kQj6]hHXa^^g6TZT>Mj6^Dm9g`^EFiONJ7[GoV2YlJ4G4B:OS
X-Complaints-To abuse@twtelecom.net
Xref x330-a1.tempe.blueboxinc.net comp.soft-sys.math.mathematica:7990

Show key headers only | View raw


On Wed, 18 Jan 2012 11:05:11 -0000, 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[]?
>

Probably the simplest way is to make use of the Listable attribute that  
you've already set. Just make one more definition:

xPrint[args__] := (xPrint[{args}];);

and:

In :=
a = 5; b = 6;
xPrint[a, b]

Out =
a =	5
b =	6

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Question about function oversky <mailcwc@gmail.com> - 2012-01-18 11:05 +0000
  Re: Question about function "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2012-01-19 10:06 +0000

csiph-web