one more // Re: Apply or Map on some parts of lists - help
- To: mathgroup at smc.vnet.net
- Subject: [mg115655] one more // Re: Apply or Map on some parts of lists - help
- From: "Scot T. Martin" <smartin at seas.harvard.edu>
- Date: Mon, 17 Jan 2011 05:41:25 -0500 (EST)
- References: <igrqdn$qot$1@smc.vnet.net> <201101161052.FAA08964@smc.vnet.net>
Having really enjoyed everyone else's solution to this problem, I thought I'd contribute one more that is based on Apply: {#1, {#1, f[#2]} & @@@ #2} & @@@ data Perhaps this one is the least intelligble of all but uses the fewest keystrokes? On Sun, 16 Jan 2011, Ray Koopman wrote: > On Jan 15, 1:46 am, dragec <culino... 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 > > These, too, will do it. Both of them are better than my first > suggestion, but I think there's still room for improvement. > > MapAt[Map[{#[[1]],f@#[[2]]}&,#]&,#,2]&/@data > > MapAt[Map[MapAt[f,#,2]&,#]&,#,2]&/@data > >
- References:
- Re: Apply or Map on some parts of lists - help
- From: Ray Koopman <koopman@sfu.ca>
- Re: Apply or Map on some parts of lists - help