'StaticArrays
'access static arrays
#include "$/inc/console.inc"
indexbase 0
' One dimension
dim as float line[4] => {1.0, 2.0, 3.0, 4.0}
printl "Line: " & cr
for i=0 to <4 : print line[i] & " " : next : printl
' Two dimensions, row, column
dim as float matrix [3*4] => {
11.0, 12.0, 13.0, 14.0,
15.0, 16.0, 17.0, 18.0,
19.0, 20.0, 21.0, 22.0 }
'Get elements
'y-> x
macro gmatrix(y,x) matrix[y*4 +x]
printl "Matrix:"
num=10
for i=0 to <3 ' row
printl "row" i ": "
for j=0 to <4 ' col
num+=1
print gmatrix(i,j) & "(" num "), "
next
next
printl
' Three dimensions, row, column, depth
dim as int cube[2*3*4] => {
11,12,13,14, 15,16,17,18, 19,20,21,22, 'row(0)
23,24,25,26, 27,28,29,30, 31,32,33,34 } 'row(1)
'Get elements
'z-> y-> x
macro gcube(z,y,x) cube[z*3*4 +y*4 +x]
num=10
printl "Cube: "
for i=0 to <2 'row
printl "row " i ": "
for j=0 to <3 'col
printl "col " j ": "
for k= 0 to <4 'depth
num+=1
print gcube(i,j,k) & "(" num "), "
next k
next j
next i
printl
' Four dimensions, row, column, depth, time
dim as int sptime[5*4*3*2] => {0}
'Fetch elements
'z-> y-> x-> w
macro gsptime(z,y,x,w) sptime[z*4*3*2 +y*3*2 +x*2 +w]
printl "Space-Time: "
printl "Ask Einstein"
printl cr & "Enter ..."
waitkey