Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Question about function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124433] Re: Question about function
  • From: Fred Simons <f.h.simons at tue.nl>
  • Date: Thu, 19 Jan 2012 05:14:27 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201201181101.GAA16655@smc.vnet.net>

This seems to work:

a=5;b=6;c=7;
Attributes[xPrint]={HoldAll};
xPrint[x__]:=(ReleaseHold[Function[z,Print[HoldForm[z]," =",Tab,z], 
HoldAll]/@ Hold[x]];)

xPrint[a, b,c,b,a]
a =    5
b =    6
c =    7
b =    6
a =    5

Fred Simons
Eindhoven University of Technology

Op 18-1-2012 12:01, oversky schreef:
> 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[]?




  • Prev by Date: Re: Can the code of a function obtain the names of its arguments?
  • Next by Date: Re: Question about function
  • Previous by thread: Re: Question about function
  • Next by thread: Re: Question about function