Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Writing to array using variable with address' topicStudent Support Forum > General > Archives > "Writing to array using variable with address"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
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: ,

Subject (listing for 'Writing to array using variable with address')
Author Date Posted
Writing to array using variable with address Leon 06/28/12 04:52am
Re: Writing to array using variable with address Nasser M. Ab... 06/29/12 07:29am
Re: Re: Writing to array using variable with ad... Leon 06/29/12 09:48am
Re: Re: Re: Writing to array using variable wit... Nasser M. Ab... 06/29/12 1:07pm
Re: Writing to array using variable with address Michael 07/02/12 00:43am
Re: Re: Writing to array using variable with ad... Leon 07/02/12 10:56am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic