# Mapping function with multiple parameters

So I am trying to print out a table using the map function. My code looks like this:

parameters = Table[{a, z}, {a, 1.251,2.5,5.251}, {z, {1, 10, 15, 25, 30}}];

Map[r+a+z &, parameters, {2}]

Unfortunately, this gets me a list with the parameters unchanged. What I want is for this function to return a list of the sort {r+1.251+1},{r+1.251+10},{r+1.251+15}...{r+2.5+1},{r+2.5+10},{r+2.5+15}... etc etc

Obviously in the final output, the numbers would actually be added up.

• Map[({r + #[[1]] + #[[2]]}) &, Flatten[parameters, 1]]
– RMMA
Oct 11, 2017 at 13:10
• or Map[Plus[r, Total@#] &, parameters, {2}]
– kglr
Oct 11, 2017 at 13:14
• @RMMA! Cool that works. What do the hashtags actually do here?
– Dio
Oct 11, 2017 at 13:14
• Map[r + Total[#] &, First@parameters] The hash mark stands for the argument; the ampersand is postfix for Function. See the documentation for Function.
– Alan
Oct 11, 2017 at 13:19
• I'm not sure if I should VTC as a simple mistake. Note that a and z are not stored or remembered in any way as references to anything in parameters. Another neat way to solve your problem would be Total[parameters, {3}] + r. Further reading is already covered in other comments Oct 11, 2017 at 14:25

## 1 Answer

Join @@ Map[{r + Total@#} &, parameters, {2}]
Join @@ Map[{r + Plus @@ #} &, parameters, {2}]
Join @@ Map[{Total[{r, #}, 2]} &, parameters, {2}]

all give

{{2.251 + r}, {11.251 + r}, {16.251 + r}, {26.251 + r}, {31.251 + r}, {3.5 + r}, {12.5 + r}, {17.5 + r}, {27.5 + r}, {32.5 + r}, {6.251 + r}, {15.251 + r}, {20.251 + r}, {30.251 + r}, {35.251 + r}}