# Use a variable to represent another variable?

I'm trying to create a list of functions by replacing variables in a template. I tried this:

In[1]:= Table[Function[{x,y}, (x + y) v], {v, {x,y}}]
Out[1]= {Function[{x, y}, (x + y) v], Function[{x, y}, (x + y) v]}


But these functions have v in them. I was expecting to get:

{Function[{x, y}, (x + y) x], Function[{x, y}, (x + y) y]}


I thought this would work because I can do something similar with Solve:

In[2]:= Table[Solve[(x + y) v == 1 && x == y], {v, {x, y}}]
Out[2]= {{{x -> -(1/Sqrt[2]), y -> -(1/Sqrt[2])}, …


This is equivalent to:

In[3]:= {Solve[(x + y) x == 1 && x == y], Solve[(x + y) y == 1 && x == y]}
Out[3]= {{{x -> -(1/Sqrt[2]), y -> -(1/Sqrt[2])}, …


It seems like it's replacing v with x/y in the Solve example, but not the Function example. Substituting Function[{x,y}, (x + y) Evaluate[v]] for Function[{x,y}, (x + y) v] doesn't help. What's going on here? How can I generate a list of similar functions?

• Function[{x, y}, (x + y) #] & /@ {x, y} Oct 14, 2020 at 22:40
• This is an effect of Function's HoldAll attribute. Use /. or something like what Bob Hanlon is suggesting to work around it. Oct 14, 2020 at 22:41
• @eyorble If that's the case, then why doesn't Evaluate[v] help? It seems like it should, according to reference.wolfram.com/language/tutorial/…
– ppm
Oct 15, 2020 at 18:35
• @ppm: Evaluate evaluates before Table, so Table's internal expression is still a function with HoldAll. Oct 15, 2020 at 18:59

Function /@ Table[(Slot[1] + Slot[2]) v, {v, {Slot[1], Slot[2]}}]

Outer[Function[{x, y}, (x + y) #] &, {x, y}]