[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Assigning a value to an index in a nested table
- From: "iain morland" <iain@...>
- Date: Sun, 10 Feb 2013 22:39:57 -0000
Hello all,
The following question probably has a super simple answer, but I've not been
able to find a solution in the list archive or other online resources. It
may be that the search terms are just too common. So I apologise in advance
if this seems idiotically simple. :-)
I have a table that is structured like so:
example={{"Red",1,2},{"Green",3,4}}
I want to define a function that changes one of the numerical values stored
in one of the nested tables. E.g. I want to change 2 in the first nested
table to 5.
I'm already able to print the contents of that index by doing this in my
function:
print((example[1])[3])
However, I can't get this to work:
((example[1])[3])=5
...and I just can't see how else I should write the syntax to assign a new
value to the specific nested index.
Although if I change the table so that it doesn't contain any sub-tables,
I'm able to do this:
example[1]=5
Can anyone advise?
Thanks for reading,
Iain