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

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: [mg115622] Re: Apply or Map on some parts of lists - help
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sun, 16 Jan 2011 05:56:07 -0500 (EST)
  • References: <igrqdn$qot$1@smc.vnet.net>

On 15.01.2011 10:46, dragec 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
>

Least typing will be achieved by

Replace[lst, {x_, y_} :> {x, f[y]}, {3}]

Procedural programmers will probably prefer:

Block[{result = lst},
  result[[All, 2, All, 2]] = Map[f, lst[[All, 2, All, 2]], {2}];
  result
]

And I like the funny looking:

Map[MapAt[Map[MapAt[f, #, 2] &, #] &, #, 2] &, lst]

Cheers,
Peter


  • Prev by Date: Re: Apply or Map on some parts of lists - help
  • Next by Date: Re: DesignerUnits 2011-01-08 for Mathematica 8, 7, 6
  • 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