develooper Front page | perl.perl6.language | Postings from May 2005

Re: (1,(2,3),4)[2]

Thread Previous | Thread Next
From:
Rod Adams
Date:
May 25, 2005 10:22
Subject:
Re: (1,(2,3),4)[2]
Message ID:
4294B462.7000501@rodadams.net
Austin Hastings wrote:

>--- Rod Adams <rod@rodadams.net> wrote:
>  
>
>>TSa (Thomas SandlaƟ) wrote:
>>
>>    
>>
>>>You mean @a = [[1,2,3]]? Which is quite what you need for multi
>>>dimensional arrays anyway @m = [[1,2],[3,4]] and here you use
>>>of course @m[0][1] to pull out the 2. I'm not sure if this
>>>      
>>>
>>automatically
>>    
>>
>>>makes the array multi-dimensional to the type system though. That
>>>      
>>>
>>is
>>    
>>
>>>if @m[0,1] returns 2 as well or if it returns the list (1,2) or
>>>      
>>>
>>whatever.
>>    
>>
>>>Is @m[0..3] valid and what does it return? And what's the type of
>>>      
>>>
>>that
>>    
>>
>>>return value(s)? I can imagine many things ranging from a two
>>>      
>>>
>>element
>>    
>>
>>>array of refs to two element arrays up to a flattened list of 4
>>>      
>>>
>>values.
>>    
>>
>>@m[0,1] is an array slice of two elements, in this case two arrayrefs
>>
>>[1,2], and [3,4].
>>@m[0;1] is a multidim deref, referencing the 4.
>>
>>    
>>
>
>Referencing the 2, I hope?
>  
>
Doh!

Yes, the 2.

-- Rod Adams


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About