I generate expressions such as
x[1] x[2] + x[2] x[3]
.
How can I can turn these expressions to functions?
My current code simply returns the above expression and then I use different values for x[i]'s to evaluate it. It would be much better if I could return a function of x[i]'s instead, for example:
f[x[1]_, x[2]_, x[3]_]:= x[1] x[2] + x[2]x[3]
Or even better to return a function of an array:
f[x_] := x[[1]] x[[2]] + x[[2]] x[[3]]