| Author |
Comment/Response |
Leon
|
06/29/12 09:48am
In Response To 'Re: Writing to array using variable with address' --------- Sorry, you got me wrong. Everything you wrote I already know. My problem is not so simple as you think it is.
If I have two-dimensional array I can write array1[[i,j]]
If I have three-dimensional array I can write array1[[i,j,k]]
But this array has different number of dimensions each time, so I can't make a variable for each index. Instead of doing so I'm trying to store indices in a dynamic array.
For example let's think this array of indices is {2,3,5,7}. It can be {1,9} or {8,7,6} next time I need it.
And let's call it "pos".
pos={2,3,5,7};
I can't just write array1[[pos]] because it would result into {array1[[2]],array1[[3]],array1[[5]],array1[[7]]}. I need array1[[2,3,5,7]].
I hope you understand now.
-----------------
=======================
I know that I can extract this element using such code:
(array1[[##]] & @@@ {address1})[[1]]
=======================
I do not understand this code.
-----------------
I don't understand also but it works. And your code with Map[] works just like array1[[pos]], if I'm not mistaken. It will not help me in my situation.
URL: , |
|