How do you define a variable amount of functions with a variable amount of arguments? I don't get the reference at all :
Clear["Global`*"]
ClearAll[Subscript]
n = 3;
cost = Table[Subscript[c, i], {i, n}];
Do[Subscript[c, i] = RandomInteger[{0, 400}]/1000, {i, n}];
price = Table[Subscript[p, i], {i, n}];
equations = Table[Subscript[eq, i], {i, n}];
Do[Subscript[eq, i] =
Subscript[p, i] - Subscript[c, i] +
1/(Sum[Subscript[p, l]*Boole[l != i], {l, n}]), {i, n}];
Do[Subscript[p, i] = Symbol["p" <> ToString[i]], {i, n}];
g1[p1_, p2_, p3_] := Evaluate[equations[[1]]];
g1 @@ {0.1, 0.1, 0.2}
I need to be able to generate g1..gn
functions with arguments gi[p1,..pn]
, is there a way to make it with some kind of loop {i,n}
?
I tried something like this without success:
Do[Symbol["g" <> ToString[i]][p__] := Evaluate[equations[[i]]], {i, n}]
I also wonder how do I explicit that the first argument is p1, the second is p2... and the nth is pn.