# How to avoid tranfer the array as a parameter [closed]

I have following array:

data = {x^2, 2*x^2, x^3};


And I must send it to the following function:

funct[x_,data_,y_]:=Module[{i,j,m,n,r},
n=Length[x];
m=Length[data[[x[[1]]]]];
r=Table[
Subscript[data[[x[[i]]]][[j]]],{i,n},{j,m}];
LinearSolve[Transpose[r].r,Transpose[r].y]
];


And running the function:

funct[x, data, y]


But I would like to avoid sending unnecessary parameter to the function. How can I declare and use an array directly in my function?

• Your code as posted does not evaluate because Subscript[x, [[1]]] is not valid input. Could you try to correct that or describe how you entered it? – Mr.Wizard May 4 '16 at 18:25
• ok, the code should be correct. "Copy" added additional tags, I don't know why. Thanks. – mathemaniac00 May 4 '16 at 18:28
• funct[x_, y_] := Module[{data = {x^2, 2 x^2, x^3}, i, j, m, n, r},...] – Bob Hanlon May 4 '16 at 18:32