2

I want to define a function with lists as variables, which has the form like

m = Table[2, {i, 5}];
f[x_, y_] = m*x + x*y;

x and y are list variables; m is a constant list with same dimension. If I evaluate this function at

xx = Table[1, {i, 5}]; yy = Table[1, {i, 5}];

I want the output to be

m*xx + xx*yy

which is

{3, 3, 3, 3, 3}

But in fact if I run the function

f[xx, yy]

I will get

{{3, 3, 3, 3, 3}, {3, 3, 3, 3, 3}, {3, 3, 3, 3, 3}, {3, 3, 3, 3, 3}, {3, 3, 3, 3, 3}}

This is not the result I want. I have tried

f @@ {xx, yy}

and

f /@ {xx, yy}

Neither one works. How should I fix fix this problem?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
JKG
  • 21
  • 1

0 Answers0