Mathematica 9 is now available
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: [mg115724] Re: Apply or Map on some parts of lists - help
  • From: "andre.robin3" <andre.robin3 at wanadoo.fr>
  • Date: Wed, 19 Jan 2011 05:27:09 -0500 (EST)
  • References: <igrqdn$qot$1@smc.vnet.net>

Elegant, clear, and purely functional :

ReplacePart[list, x : {_, 2, _, 2} :> f[ Extract[list, x]]]

---> {

{{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]}}}}

Or better (if each line contain more than 2 elements) :

ReplacePart[list, x : {_, Except[1], _, 2} :> f[ Extract[list, x]]]

"dragec" <culinovic at gmail.com> a écrit dans le message de news: 
igrqdn$qot$1 at smc.vnet.net...
> 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
> 




  • Prev by Date: Re: InterpolatingPolynomial error message
  • Next by Date: Re: SetOptions does not work with Grid
  • Previous by thread: Re: Apply or Map on some parts of lists - help
  • Next by thread: why need to check if inline doc is already defined?