Hello,
I have a list
x = {a, b, c, d}
and can be mapped to the function using
Map[f, x]
Say if the function takes two arguments, is this possible to get
{f[arg1,a], f[arg1,b], f[arg1,c], f[arg1,d]}
many thanks!
Hello,
I have a list
x = {a, b, c, d}
and can be mapped to the function using
Map[f, x]
Say if the function takes two arguments, is this possible to get
{f[arg1,a], f[arg1,b], f[arg1,c], f[arg1,d]}
many thanks!
f[arg1,#]&/@x
Here I used an anonymous function. Note that Map[f,x] is the same as:
f/@x
The pure function approach is usually best. If for some reason you want to avoid that, could curry the thing as below.
f[arg_][x_] := f[arg,x]
Now you can do
Map[f[arg1], list]
Thread works, too.
In[1]:= x = {a, b, c, d};
In[2]:= Thread[ f[arg1, x] ]
Out[2]= {f[arg1, a], f[arg1, b], f[arg1, c], f[arg1, d]}