User blog comment:Edwin Shade/How Do I Evaluate BEAF Arrays In Two Dimensions ?/@comment-30754445-20170827183955

1. If the first row has more than 2 numbers, multidimensional arrays expand exactly like linear arrays. You expand only the first row (according to the usual rules), but whenever you are called to copy the array into an entry, you copy the entire multidimensional array into that spot.

For example:

1. You already know that {2,3,5} expands to {2,{2,2,5},4}. Another way to write this is:

{2,3,5} = {2,X,4} where X={2,2,5}.

So

{2,3,5 (1) 7,11,13 (1) 17,19,23}

Would expand to:

{2, X, 4 (1)

7,11,13 (1)

17,19,23}

Where X is { 2,{2,2,5},4 (1) 7,11,13 (1) 17,19,13 }

2. If the first row has exactly two numbers (which we'll call b and x)  then we look at the first number beyond the first row that is bigger than 1. We'll call it y.

To expand such an array:

(1) we decrement y by 1.

(2) we delete the second entry (x).

(3) we build a geometrical structure with side x and fill it up with b's up to (and not including) y

Sounds confusing? An example will make things clear:

Say we have the 2D array {2,3 (1) 5,7}. Here b=2 and x=3.

First we do 5-1=4 and get:

{2,3 (1) 4,7}

Then we erase the '3':

{2 (1) 4,7}

An finally, we fill in array with 2's all the way up to the third entry (which is now the 4):

{2,2,2 (1) 4,7}

Similarly, if we had {2,5 (1) 8,11}, this will expand to:

{2,2,2,2,2 (1) 7,11}

(5 twos, because here x is 5)

Of-course, the 3rd entry could be further away from just "the next row". For example, look at this 3D array:

{2,3 (2) 5,7}

The '(2)' means that the "5,7" is in a different plane, so we need to fill an entire 3x3 square with twos:

{2,3 (2) 5,7} = {2,2,2 (1) 2,2,2 (1) 2,2,2 (2) 4,7}

And that's it (I think) for ordinary dimensional arrays.