MathGroup Archive 2003

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

Search the Archive

Re: How to copy pattern from one expression to another?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45260] Re: How to copy pattern from one expression to another?
  • From: bobhanlon at aol.com (Bob Hanlon)
  • Date: Wed, 24 Dec 2003 17:42:14 -0500 (EST)
  • References: <bsbn05$lri$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Make f Listable and use Map:

xx={{x11,x12,x13},x2,x3,x4,{x51,x52},x6,{x71,x72},x8};

SetAttributes[f, Listable];

f /@ xx

{{f[x11], f[x12], f[x13]}, f[x2], f[x3], f[x4], 
  {f[x51], f[x52]}, f[x6], {f[x71], f[x72]}, f[x8]}


Bob Hanlon

In article <bsbn05$lri$1 at smc.vnet.net>, "Nico" <pipponep at hotmail.com> wrote:

<< Here's my issue: I have a vector such as
XX={{x11,x12,x13},x2,x3,x4,{x51,x52},x6,{x71,x72},x8} and I would like to
apply the same function F[x_] to each single element in it. This is indeed
pretty straightforward even to a very basic user like I am: I can first
Flatten[XX] and then apply F[Flatten[XX]]. What I get is then
YY={F[x11],F[x12],F[x12],...}.
The question is: how can I then have YY with the same pattern of XX, that is
YY_hat={{F[x11],F[x12],F[x12]},F[x2],....,{F[x51],F[x52]},F[x6],{F..,F}}?
I have tried but I'm afraid I cannot focus exactly the way I should approach
the problem.


  • Prev by Date: Re: Usage of "//" Operator
  • Next by Date: Re: Compile
  • Previous by thread: Re: How to copy pattern from one expression to another?
  • Next by thread: Re: How to copy pattern from one expression to another?