Skip to main content

Timeline for How to Set parts of indexed lists?

Current License: CC BY-SA 3.0

8 events
when toggle format what by license comment
Jun 22, 2012 at 13:35 comment added Leonid Shifrin @gwr Indexed variables are really a hash-table under the name of the corresponding symbol, and it points at values rather than assignable memory locations, which is IMO quite natural. I think, my solution gives you the closest to "truly indexed symbols" you can get, since I am using intermediate symbols, which are, indeed, "truly indexed".
Jun 22, 2012 at 13:24 comment added gwr @jVincent, thank you for expanding your answer and it does help to clear the issue. Nevertheless it is a 'pity' that even the subscripted variable cannot be addressed by Part and Set. Essentially then you cannot have a truly indexed symbol?
Jun 22, 2012 at 12:23 history edited jVincent CC BY-SA 3.0
added 11 characters in body
Jun 22, 2012 at 11:37 comment added jVincent @gwr I expanded my answer a bit, the important note is that matM[a] is not a symbol, and this was also what I was hinting towards originally. You can have some behavior which resembles what you have with symbols, but in other situations it falls short exactly because it isn't a symbol.
Jun 22, 2012 at 11:34 history edited jVincent CC BY-SA 3.0
Expanded on explanation
Jun 22, 2012 at 9:47 comment added gwr Thanks. But using the 'fixed' argument in a function is explicitly suggested in the Mathematica documentation (reference.wolfram.com/mathematica/tutorial/…) and for example in Sal Mangano's "Mathematica Cookbook". It is of course possible to make this an array adding the index dimension, but if - as in my real case - you want to use symbols like matM[a] is not so easy to do.
Jun 22, 2012 at 9:45 comment added Szabolcs Saying that "it's a call to the function with the argument 1" is a bit misleading. It's quite common to use variables named x[1], x[2], x[3], ... for symbolic manipulation or other tasks when we don't know beforehand how many variables we'll be needed, or when there's a large number of variables that we need to work with and it's inconvenient to refer to them 'manually'. I think this is clear to the OP.
Jun 22, 2012 at 9:40 history answered jVincent CC BY-SA 3.0