# Substitution and make a list $List[f[A, x]@{a1, a2}] =? \{f[a1,x],f[a2,x]\}$

For given list $$\{a_1, \cdots, a_n\}$$ and a function $$f[a_,x]$$, I want to make a function whose input is $$[\{a1,\cdots, a_n\}, f[A,x]]$$ and produce $$\{ f[a_1,x], f[a_2, x], \cdots, f[a_n,x]\}$$, i.e., plugging $$a_1, a_2,$$ into $$a$$ and make a list out of $$f$$.

My first trial was

 List[f[#, x]@{a1, a2}]


  f@a1


produce $$f[a1]$$, and my simple idea was using this but it seems not working well

Simply I can make

 List[f[x, y] //. {x -> a1}, f[x, y] //. {x -> a2}]


and obtain the desired result but I want to make a simple code, not the code above.

• f[#, x] & /@ {a1, a2}
– Syed
Apr 13, 2023 at 6:11
• Alternatively, you can just make a Table: Table[f[k, x], {k, {a1, a2}}]. Apr 13, 2023 at 6:30

So many ways.

Table[f[i, x], {i, {a1, a2, a3}}]


But it's probably more typical to use table with an iterator expression rather than an explicit list. With an explicit list, Map is probably more typical:

f[#, x] & /@ {a1, a2, a3}


If you need to build something out of pieces fetched and brought together, might want

OperatorApplied[f][x] /@ {a1, a2, a3}


I often do my own currying with SubValues:

f[param_][arg_] := f[param, arg];
f[x] /@ {a1, a2, a3}


This actually switched the order, but I like my parameters to come before regular arguments. Or course, you could have done

f[param_][arg_] := f[arg, param]


Or

Thread[f[{a1, a2, a3}, x]]


Construct sometimes comes in handy. The list goes on...