MathGroup Archive 2011

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

Search the Archive

Re: Apply or Map on some parts of lists - help

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115608] Re: Apply or Map on some parts of lists - help
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Sun, 16 Jan 2011 05:53:23 -0500 (EST)

You might puzzle out a way to use MapAt, but Replace is easier:

Replace[{{{TITLE1}, {{x11, y11}, {x12, y12}, {x13, y13}, {x14,
      y14}}}, {{TITLE1}, {{x21, y21}, {x22, y22}, {x23, y23}, {x24,
      y24}}}, {{TITLE1}, {{x31, y31}, {x32, y32}, {x33, y33}, {x34,
      y34}}}}, {x_, y_} :> {x, f@y}, {3}]


{{{TITLE1}, {{x11, f[y11]}, {x12, f[y12]}, {x13, f[y13]}, {x14,
     f[y14]}}}, {{TITLE1}, {{x21, f[y21]}, {x22, f[y22]}, {x23,
     f[y23]}, {x24, f[y24]}}}, {{TITLE1}, {{x31, f[y31]}, {x32,
     f[y32]}, {x33, f[y33]}, {x34, f[y34]}}}}

In looking at this, it was helpful to evaluate

{{{TITLE1}, {{x11, y11}, {x12, y12}, {x13, y13}, {x14,
      y14}}}, {{TITLE1}, {{x21, y21}, {x22, y22}, {x23, y23}, {x24,
      y24}}}, {{TITLE1}, {{x31, y31}, {x32, y32}, {x33, y33}, {x34,
      y34}}}} // TreeForm

Notice that the x and y values are at level 4 (the tree starts at zero at  
the top), and the {x, y} pairs are at level 3.

Bobby

On Sat, 15 Jan 2011 03:46:36 -0600, dragec <culinovic at gmail.com> wrote:

> Dear,
> I have
>
> List like:
>
> { {{TITLE1},{{x11,y11},{x12,y12},{x13,y13},{x14,y14}}},
>   {{TITLE1},{{x21,y21},{x22,y22},{x23,y23},{x24,y24}}},
>   {{TITLE1},{{x31,y31},{x32,y32},{x33,y33},{x34,y34}}}
> }
>
> So, I would like to apply some function (eg. #/3.6&) to all y's.
> Is there any elegant way to do this.
> I Know that you know how to do this. :)
>
> THX
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: NSolve unable to find all possible roots
  • Next by Date: Re: Interpolation of a tabulated function
  • Previous by thread: Re: Apply or Map on some parts of lists - help
  • Next by thread: Re: Apply or Map on some parts of lists - help