Re: Apply function to parts of a list
- To: mathgroup at smc.vnet.net
- Subject: [mg86285] Re: [mg86224] Apply function to parts of a list
- From: Curtis Osterhoudt <cfo at lanl.gov>
- Date: Fri, 7 Mar 2008 02:31:51 -0500 (EST)
- Organization: LANL
- References: <200803060759.CAA29253@smc.vnet.net>
- Reply-to: cfo at lanl.gov
You could try using replacements on the second of each pair: data/.{a_, b_}->{a, 2b} Or termwise multiplication: #*{1,2}&/@data On Thursday 06 March 2008 00:59:51 guerom00 wrote: > Hi all, > > Very often, I find myself having datas to plot of this form : > > data={{x1,y1},{x2,y2},{x3,y3}...{xn,yn}} > > So, very conventional : a list of abscissa and ordinate. Now, let's say I > want to multiply by 2 all my ascissa. Right now, I write : > > MapAt[2*#&,data,Table[{i,1},{i,1,Length[data]}]] > > It's OK but I isn't there another way to achieve this as I find this rather > "involved" for such a simple thing ? > > Thanks in advance. -- ========================================================== Curtis Osterhoudt cfo at remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html ==========================================================
- References:
- Apply function to parts of a list
- From: guerom00 <guerom00@gmail.com>
- Apply function to parts of a list