From: Richard Fateman on 21 Feb 2010 04:23 pipehappy 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 > Maybe you should look at MapThread. You could do this: newab = Table[Table[ab[[i]][[j]], {i, 1, 3}], {j, 1, 2}] MapThread[(#1+#2)&,newab] or you could define a function f[{x_,y_}]:= x+y and use Map[f,ab] but that is not a pure function.
First
|
Prev
|
Pages: 1 2 3 Prev: some question about "FourierTransform" Next: Manipulate piecewise functions, |