RE: Map function which adds last two numbers of a list

*To*: mathgroup at smc.vnet.net*Subject*: [mg73563] RE: [mg73530] Map function which adds last two numbers of a list*From*: "David Annetts" <davidannetts at aapt.net.au>*Date*: Thu, 22 Feb 2007 04:26:03 -0500 (EST)*References*: <200702210646.BAA18238@smc.vnet.net>

Hi Christopher, > 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}} > > I could easily use the Table command to construct this new > table, but it would be nicer if I new how to Map some > function on z that would produce the same result. You can use a rule for this:- zz = z /. {a_, b_, c_, d_} -> {a, b, c + d} Regards, Dave.

**References**:**Map function which adds last two numbers of a list***From:*"Christopher Pike" <crpike@ucdavis.edu>