El lunes, 17 de febrero de 2014 19:03:55 UTC-6, Patrick O'Leary escribió:
>
> On Monday, February 17, 2014 6:57:10 PM UTC-6, David P. Sanders wrote:
>>
>> Hi,
>>
>> Suppose I have the following:
>>
>> r = rand(5, 5)
>>
>> I can select a single element of the array r using
>>
>> r[3, 4]
>>
>> Now suppose that I have the position [3, 4] stored in a variable as
>>
>> pos = [3, 4]
>>
>> How can I use pos as the index for selecting the *single* element r[3, 4]?
>> I would like to do r[pos], but this returns a *two*-element array, given 
>> by the elements numbered 3 and 4 in the linear ordering of the array r.
>>
>
> You're looking for r[pos...]. The ellipsis operator will splat the 
> elements of pos as a comma-separated list of arguments. 
>


Many thanks for the 3 super-fast replies! "r[pos...]" is indeed exactly 
what I was looking for, thanks.
Maybe this could be included in the array docs?

Best,
David.
 

Reply via email to