I'm trying to do something like this:
test = {x, y};
With[{test[[1]] = 3}, x/y]
However, the following error is printed:
With::lvset: "Local variable specification {test[[1]]=3} contains test[[1]]=3, which is an assignment to test[[1]]; only assignments to symbols are allowed"
I'm assuming this is because Mathematica treats the list elements as expressions and not as symbols correct? Setting x directly works, but I need the index for a loop functionality. Any hint on how to force Mathematica to interpret test[[1]] as a symbol?
With[{# = 3}, x/y] &[test[[1]]]ifxhas no value. – Kuba May 11 '15 at 11:49Withhas attributeHoldAllhencetest[[1]]isn't evaluated toxprior to trying to make the assignment. – Bob Hanlon May 11 '15 at 13:12Withis the problem. Set isHoldFirsttoo. – Kuba May 11 '15 at 13:46