Re: multiple variables in pure function used in map.
- To: mathgroup at smc.vnet.net
- Subject: [mg107633] Re: [mg107632] multiple variables in pure function used in map.
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 21 Feb 2010 04:22:44 -0500 (EST)
- Reply-to: hanlonr at cox.net
ab = {{1, 2}, {2, 3}, {3, 4}}; (#1 + #2) & @@@ ab {3,5,7} which is shorthand for Apply[(#1 + #2) &, ab, 1] {3,5,7} However, for this specific case Plus @@@ ab {3,5,7} Total /@ ab {3,5,7} Bob Hanlon ---- pipehappy <pipehappy at gmail.com> wrote: ============= Hi, All Is there a way to use multiple variables in pure function with map. What I want to do is like this: ab = {{1, 2}, {2, 3}, {3, 4}}; (#[[1]] + #[[2]]) & /@ ab {3, 5, 7} Instead of refer to elements in list I want to use multiple variables in pure function. something like this: ab = {{1, 2}, {2, 3}, {3, 4}}; (#1 + #2) & /@ ab To do the same thing as the above example. Best -- pipehappy