Path: news.daimi.aau.dk!not-for-mail From: Stephan Erbs Korsholm Newsgroups: comp.lang.beta Subject: Re: More-dimensional arrays in BETA Date: Wed, 14 Jan 1998 11:12:04 +0100 (MET) Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 50 Approved: mailtonews@daimi.aau.dk Distribution: world Message-ID: <199801141012.LAA24585@noatun.mjolner.dk> Reply-To: Stephan Erbs Korsholm NNTP-Posting-Host: daimi.daimi.aau.dk Xref: news.daimi.aau.dk comp.lang.beta:11349 Tricos Software writes: > Hello! > > I have a question regarding the possibility of constructing two- or = > more-dimensional arrays with the BETA programming-language. > Is it possible do define such arrays, and if, how? > Do I have to use some tricks? > > I hope that someone here can help me. Below you will find at least one way of using a two-dimentional array: ------------------- code starts here --------------------- (# height,width: @integer; matrix: [0] ^row; row: (# xs: [width] @integer #) do 10->width; 15->height; height->matrix.new; (for rowCounter: height repeat &row[]->matrix[rowCounter][]; (for xsCounter: width repeat rowCounter+xsCounter->matrix[rowCounter].xs[xsCounter] for) for); (for rowCounter: height repeat (for xsCounter: width repeat matrix[rowCounter].xs[xsCounter]->putInt; ' '->putText for); newline for) #) ---------------------- code ends here ---------------------- This can easily be extended to more dimensions. The first loop initializes the array to hold som integers (this could of course be anything you want), the second loop prints it out. There might be easier ways of doing it. Regards, Stephan Korsholm.