Here is the code:
DEF SIZE A OUT X,Y VAR T=A[1,0],B[0],L=LEN(A) A[1,0]=1<<31 COPY B,A FOR Y=0 TO L-1 IF B[Y]==A[1,0] THEN BREAK NEXT A[1,0]=T X=L/Y ENDUsage:
DIM MYARRAY[12,8] SIZE MYARRAY OUT X,Y ?"DIM MYARRAY[";X;",";Y;"]"How it works: When you have a two dimensional array, copying it to a new array will convert it into a one dimensional array. So we can change the value in [1,0] and see what index it gets mapped to. That will give us the size of one dimension, we can easily calculate the other. Note: The smallest array that this works on is [2,1]. The time complexity of this algorithm is O(X*Y+X), copying the whole array is linear, then we have to loop through Y once more, to get O(X*(Y+1)). I believe this is the fastest algorithm to do this. I'd love to see if someone can do better.