arrays

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

arrays

Andreas Zieritz-2
How can I find out the dimension of an 2D-array.

Guess I have this thing (not tested)

***********

class test
properties public
        a = double[3,3]
...

a[0,0] = 1
a[0,1] = 1.6847
...

method list(b = double[,])
loop i = 0 to FirstDimensionofArray
        loop j = 0 to SecondDimensionofArray
                print b[i,j]
        end j
end i

**************

How do I get the first and second dimension of an array?

--
Servus,
        Andreas
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: arrays

Mike Cowlishaw-2


Java actually implements multi-dimensional arrays as arrays of arrays, so
to get the first dimension of (for example) a=int[3,5] one can just say
a.length.  To get the second dimension (assuming all the same length, which
they needn't be):  a[0].length

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Mike Cowlishaw, IBM Fellow
mailto:[hidden email]  --  http://www2.hursley.ibm.com


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>

Reply | Threaded
Open this post in threaded view
|

Re: arrays

Andreas Zieritz-2
In reply to this post by Andreas Zieritz-2
Myself wrote:

>         loop j = 0 to SecondDimensionofArray
>                 print b[i,j]
                  ^^^^^

Basic programmers never die, they just gosub and never return :-)

Thanks for the help, Mike.

--
Servus,
        Andreas
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe from this mailing list ( ibm-netrexx ), please send a note to
[hidden email]
with the following message in the body of the note
unsubscribe ibm-netrexx <e-mail address>