#1✎ 90HackTheWorldsSecond YearMy account is over 2 years oldWebsiteSummer 2016 Contest ParticipantI participated in the SmileBASIC Source Summer 2016 Contest!Programming ContestReadingI like to read books!HobbiesSo I figured out how to determine the length of dimensions in 2D arrays. I don't want to explain how it works right now, so I'll just give you the key: E245W8V
I also learned that you can COPY between arrays with fewer or lesser dimensions as long as there are enough total elements, which is strange.
Posted
Edited
by HackTheWorlds
#2✎ 188212Me21Syntax HighlighterReceived for creating the code syntax highlighter on SBSNight PersonI like the quiet night and sleep late.Express Yourselfbroken key
Posted
#3✎ 90HackTheWorldsSecond YearMy account is over 2 years oldWebsiteSummer 2016 Contest ParticipantI participated in the SmileBASIC Source Summer 2016 Contest!Programming ContestReadingI like to read books!HobbiesFixed.
Posted
Well, I do.
FILL, in the built-in help, is shown as FILL Array, Value [, Offset [, Number of elements]]. 'Offset' is a single number. In a 1D array, it corresponds exactly to the index. In a 2D array, it corresponds to (second index + (second dimension size)*(first index)). For 3D, (third index + (third dimension size)*(second index + (second dimension size)*(first index))). For 4D, the pattern continues.
So, the program uses COPY to copy the array in question to a placeholder array. The placeholder array's elements are FILLed with their own 'offset' value. Then, array index [1,0] contains the size of the second dimension, the number of times this fits into the LEN of the array is the size of the first dimension.
The code assumes the size of the first dimension is at least 2. It can be adapted for 3D, 4D arrays, but there is no way (so far as I know) to know, given just an array, how many dimensions it has.
Posted
#5✎ 190DFrostExpert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming StrengthI see how you put
FILL A%, 42
They always said 42 was the answer to the universe.
Anyways, this is AWESOME
Posted
Edited
by DFrost