Re: 3 dimension array
- Posted by christian.cuvier at education.gouv.fr Aug 22, 2002
- 405 views
----- Original Message ----- From: "C. K. Lester" <cklester at yahoo.com> To: "EUforum" <EUforum at topica.com> Subject: Re: 3 dimension array > > > What is the code needed to create a 3 dimensional array? In Basic it is > > a simple Dim somearray(a,b,c). I assume that I can take the code for 3 > > dimensions to configure one for 4 and possible 5 dimensions. > > > > The arrays will strictly house integers and will initially be filled > > with zeroes. The multiple dimensions are needed to access unique number > > combinations representing time, space and values. > > First, you'll probably want to stop thinking in terms of arrays in the > traditional sense, and start grasping for the sequence. I think. hmmmmm. > > Here's what a two dimensional sequence looks like: > > { > { One, Two, Three, Four }, > { Two, Two, Three, Four }, > { Three, Two, Three, Four } > } > > myArray[3] = {Three, Two, Three, Four} > myArray[3][4] = Four > > Here's what a three dimensional sequence looks like: > > { > { > {One1, Two, Three, Four }, > { Two1, Two, Three, Four }, > { Three1, Two, Three, Four } > }, > { > {One2, Two, Three, Four }, > { Two2, Two, Three, Four }, > { Three3, Two, Three, Four } > } > } > > myArray[2] = > { > {One2, Two, Three, Four }, > { Two2, Two, Three, Four }, > { Three3, Two, Three, Four } > } > > myArray[2][3] = { Three3, Two, Three, Four } > > myArray[2][3][4] = Four > > There are libraries that will help you deal with sequences as arrays, and > even using a database program (like the EUPHORIA database system) would be > reasonable. > > I think. > > -ck > > > > Dear Darcman, Indeed, Ephoria has no array, it has sequences, as explained above. You may thi,k of sequences as trees, except that the root is hidden (it is the sequence container itself). If you want to create a 3-dimensional matrix m with zeroes, with initial item number p,q and r, you can use te following statement: m=repeat(p,repeat(q,repeat(r,0))) This is a sequence of p idntical sequences. Each of these is a sequence of q identical subsequences, each of which is a sequence of r zeroes. Type does not matter. Alter elements and layout as you wish. Regards. Chris