User blog:DrCeasium/HAN: multidimensional arrays

By request, I am going to write a blog post about how multidimensional arrays work (and the dreaded w(k)/ operator). If there is anything you feel could need a bit (or a lot) more work, tell me in the comments and i'll work on it. To start off with, we can look at the w(k)/ operator:

The w(k)/ operator
The w(k)/ operator is formally(ish) defined as follows:

◆ can be anything ◇ contains only 1's and separators ○ either starts with a separator or a ']'. ▮ represents any number of '['s ▲ any w/ chain ▼ an array with something before the first (k) divider ▽ an array without anything before the first (k) divider ▬ a string of ▽w(x)/'s (any x) and empty arrays ([1]s).</li> R1: ◆[▬▽w(k)/[q◆]▲]◆ = ◆[▬[1(k)1(k)1(k)...(k)1(k)2▽]w(k)/[1◆]▲]◆, where there are q 1's. This rule means that w(k)/ takes precedence over parts of the array in higher parts of space than (k).</li> R2: ◆[▬▼w(k)/[q◆]▲]◆. The ▼ will be evaluated using non-w(k)/ rules. When it requires to either replace the receiving array with ▼ with the active entry changed to 1, or to make a w/ chain of ▼'s with the active entry decreased by one, instead of just using ▼ with the changes mentioned before, use ▼w(k)/[q◆]▲, with the changes on ▼ mentioned before.</li> S1: ◆[◆]w(k)/1◆ = ◆[◆]◆ (remove trailing 1's from the chain).</li> S2: If no (k) is specified for w(k)/, it defaults to 0 (leading to ,s being used).</li> Additional information can be specified about the workings of the w(k)/ operator, for example: works in the 2nd row of the 3rd plane.</li></ul> This is not obvious in how it works or what it does, so here is an example: <ul>(S2 is used throughout) 4![1]w/[3] =(by R1) 4![1,1,2]w/[1] = 4![1,[1,1]w/[1]]w/[1] =(by R2) 4![1,[1]w/[1]]w/[1] = 4![1,[1]w/4]w/[1] = 4![1,[1,1,1,2]w/1]w/[1] =(by S1) 4![1,[1,1,1,2]]w/[1] = (standard linear rule stuff here) 4![1,1,1,3],3,3w/[1] = (more linear stuff) 4![1,[1,1,2],3,2],3,3w/[1] = (more linear) 4![1,[4,3],3,2],3,3w/[1] =(by R2) 4!1,[[[1,3],3,2],3,3w/[1],[3,3],3,2],3,3w/[1] = ...skip to when, finally, this happens... = 4![...[1]w/[1]...] = 4![...[1]w/4...] = 4![...[1,1,1,2]w/1...] =(by S1) 4![...[1,1,1,2]...]</li></ul>

If, in this example, the w/ was in the form w(k)/, then the example would work the same way, but with (k) separators rather than ,'s being formed every time R1 was used.

Multidimensional arrays
Again, here is the formal(ish) definition (includes linear and uses the shapes described above):

<ul>R1: n![◇1,▮x◆] = n![◇[◇1,▮1◆],▮x-1◆]</li> R2: iff a &gt; 0, n![◇1(a)▮x◆] = n![◇1(a)▮x-1◆]w(a-1)/[◇1(a)▮x-1◆]w(a-1)/...w(a-1)/[◇1(a)▮x-1◆], acting on the position of the 1.</li> R3: n![▮x◆] = ((...(n![▮x-1◆])![▮x-1◆]...)![▮x-1◆])![▮x-1◆]</li> R4: n![◇▮[1◆]◆]. Work on the [1◆], using all the rules until the 1 becomes non-1, or S1 can be used on it.</li> S1: n![◆▮[1]◆] = n![◆n◆] iff the ▮[1] was the active entry</li> S2: n![◆(a)1○] = n![◆○], for any a (including (0), or a comma).</li></ul>

This is fairly simple, and most of the complexity comes from the w(k)/ operator. It basically means that if a two separators have only a 1 between them, and the second is greater than the first, remove the first separator and the 1. If the active entry (x) is directly after a separator ((a)), decrease k by 1, and then form a w(a-1)/ chain with the new bracket, length n, with all the w(a-1)/'s acting on the position of the receiving entry at time of formation of the chain.