Re: Map function which adds last two numbers of a list
- To: mathgroup at smc.vnet.net
- Subject: [mg73551] Re: Map function which adds last two numbers of a list
- From: albert <awnl at arcor.de>
- Date: Wed, 21 Feb 2007 06:04:25 -0500 (EST)
- References: <ergqrb$jg0$1@smc.vnet.net>
Christopher Pike wrote: > > Hi, > Consider this: > > z = {{1,4,5,6},{7,8,9,1},{1,2,4,3}} > > I'd like to Map a function onto z which would replace the last two items > with their sum: > > {{1,4,11},{7,8,10},{1,2,7}} This is one of many formulations that would do what you want: Map[Append[#[[{1,2}]],Plus@@#[[{3,4}]]]&,z] hth, albert