0

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?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
F. E.
  • 45
  • 5

0 Answers0