Let's say I have a function
formula[x_List] := (x[[1]] - x[[2]]) + (x[[3]] - x[[4]]);
and I want to pass it a variable and get back the unevaluated formula with these inputs in place, so for example with input {1,2,3,4} I would get back
Out[]= (1-2)+(3-4)
I do not want it to return strings; if I copy the output and paste it somewhere, I want it to be executable. I also don't want it to do any math on the function; if x[[1]]==x[[2]]
, it should not collapse x[[1]]-x[[2]]
to 0. All I want is pattern substitution.
I figure the answer involves Hold[]
, but I have not been able to get the results I want.