aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-07-27 21:24:34 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-07-27 21:24:34 -0400
commit00abceb4b2b43acd7fbb100aac41f759f643f5e7 (patch)
tree018fee87fc00d2bf600323919f51c76a8bfe4d51 /docs
parenta6a234c75bf394fd3fcfc2c85a30c5f08fa9f744 (diff)
Array diagram
Diffstat (limited to 'docs')
-rw-r--r--docs/doc/array.html76
1 files changed, 76 insertions, 0 deletions
diff --git a/docs/doc/array.html b/docs/doc/array.html
index 752dcd39..9cf74517 100644
--- a/docs/doc/array.html
+++ b/docs/doc/array.html
@@ -9,6 +9,82 @@
<p>In BQN, as in APL, arrays are multidimensional, instead of strictly linear. Languages like Python, Javascript, or Haskell offer only one-dimensional arrays with <code><span class='Value'>[]</span></code> syntax, and typically represent multidimensional data with nested arrays. Multidimensional arrays have fundamental differences relative to this model.</p>
<p>BQN's arrays are immutable, meaning that an array is entirely defined by its attributes, and there is no way to modify an existing array, only to produce another array that has changes relative to it. As a result, an array can never contain itself, and arrays form an inductive type. BQN's <a href="lexical.html#mutation">mutable</a> types are operations and namespaces.</p>
<p>An array might also have a <a href="fill.html">fill element</a> that captures some structural information about its elements and is used by a few operations. The fill, as an inferred property, isn't considered to truly be part of the array but is instead some information about the array that the interpreter keeps track of. So it's out of scope here.</p>
+<svg viewBox='-36 -15 544 426'>
+ <g fill='currentColor' stroke-linecap='round' text-anchor='middle' font-size='14' font-family='BQN,monospace'>
+ <rect class='code' stroke-width='1.5' rx='12' x='-4' y='0' width='480' height='396'/>
+ <g font-size='24px' opacity='0.9' text-anchor='start'><text dy='0.33em' x='23' y='-2'>Array properties</text></g>
+ <rect fill='#7f651c' opacity='0.1' x='281' y='14' width='46' height='368'/>
+ <path class='bluegreen' stroke-width='3' style='fill:none' opacity='0.8' d='M440 377h21v-21M114.5 83h-31.5v31.5m0 16v12'/>
+ <g font-size='18px' text-anchor='end'>
+ <text dy='0.33em' x='128' y='104'><tspan class='Number'>4</tspan></text>
+ <text dy='0.33em' x='192' y='104'><tspan class='Number'>25</tspan></text>
+ <text dy='0.33em' x='256' y='104'><tspan class='Number'>64</tspan></text>
+ <text dy='0.33em' x='320' y='104'><tspan class='Number'>121</tspan></text>
+ <text dy='0.33em' x='384' y='104'><tspan class='Number'>196</tspan></text>
+ <text dy='0.33em' x='448' y='104'><tspan class='Number'>4</tspan></text>
+ <text dy='0.33em' x='128' y='140'><tspan class='Number'>25</tspan></text>
+ <text dy='0.33em' x='192' y='140'><tspan class='Number'>64</tspan></text>
+ <text dy='0.33em' x='256' y='140'><tspan class='Number'>121</tspan></text>
+ <text dy='0.33em' x='320' y='140'><tspan class='Number'>196</tspan></text>
+ <text dy='0.33em' x='384' y='140'><tspan class='Number'>4</tspan></text>
+ <text dy='0.33em' x='448' y='140'><tspan class='Number'>25</tspan></text>
+ <text dy='0.33em' x='128' y='212'><tspan class='Number'>64</tspan></text>
+ <text dy='0.33em' x='192' y='212'><tspan class='Number'>121</tspan></text>
+ <text dy='0.33em' x='256' y='212'><tspan class='Number'>196</tspan></text>
+ <text dy='0.33em' x='320' y='212'><tspan class='Number'>4</tspan></text>
+ <text dy='0.33em' x='384' y='212'><tspan class='Number'>25</tspan></text>
+ <text dy='0.33em' x='448' y='212'><tspan class='Number'>64</tspan></text>
+ <text dy='0.33em' x='128' y='248'><tspan class='Number'>121</tspan></text>
+ <text dy='0.33em' x='192' y='248'><tspan class='Number'>196</tspan></text>
+ <text dy='0.33em' x='256' y='248'><tspan class='Number'>4</tspan></text>
+ <text dy='0.33em' x='320' y='248'><tspan class='Number'>25</tspan></text>
+ <text dy='0.33em' x='384' y='248'><tspan class='Number'>64</tspan></text>
+ <text dy='0.33em' x='448' y='248'><tspan class='Number'>121</tspan></text>
+ <text dy='0.33em' x='128' y='320'><tspan class='Number'>196</tspan></text>
+ <text dy='0.33em' x='192' y='320'><tspan class='Number'>4</tspan></text>
+ <text dy='0.33em' x='256' y='320'><tspan class='Number'>25</tspan></text>
+ <text dy='0.33em' x='320' y='320'><tspan class='Number'>64</tspan></text>
+ <text dy='0.33em' x='384' y='320'><tspan class='Number'>121</tspan></text>
+ <text dy='0.33em' x='448' y='320'><tspan class='Number'>196</tspan></text>
+ <text dy='0.33em' x='128' y='356'><tspan class='Number'>4</tspan></text>
+ <text dy='0.33em' x='192' y='356'><tspan class='Number'>25</tspan></text>
+ <text dy='0.33em' x='256' y='356'><tspan class='Number'>64</tspan></text>
+ <text dy='0.33em' x='320' y='356'><tspan class='Number'>121</tspan></text>
+ <text dy='0.33em' x='384' y='356'><tspan class='Number'>196</tspan></text>
+ <text dy='0.33em' x='448' y='356'><tspan class='Number'>4</tspan></text>
+ </g>
+ <g font-size='18' transform='rotate(-90)'><text dy='0.33em' x='-284' y='54.4'>Axis 0</text></g>
+ <text dy='0.33em' x='304' y='39.2'>Position 3</text>
+ <g transform='translate(304,320)'>
+ <path class='purple' stroke-width='2' style='fill:none' d='M-22.4 -16.2h44.8v32.4h-44.8z'/>
+ <text dy='0.33em' x='0' y='-43.2'>Element at 2‿0‿3</text>
+ <text dy='0.33em' x='0' y='-27'>Value 64</text>
+ </g>
+ <g class='yellow'>
+ <g font-size='22px'>
+ <text dy='0.33em' x='22.4' y='77'>3</text>
+ <text dy='0.33em' x='54.4' y='73.4'>2</text>
+ <text dy='0.33em' x='80' y='66.2'>6</text>
+ </g>
+ <text dy='0.33em' x='41.6' y='53.6'>Shape</text>
+ </g>
+ <g class='bluegreen' font-size='16'><text dy='0.33em' x='51.2' y='33.8'>Rank 3</text></g>
+ <path stroke='currentColor' stroke-width='1.5' opacity='0.1' d='M89.6 73.2H459.6M32 93.2V381.2M64 93.2V155.2'/>
+ <path class='purple' stroke-width='2' style='fill:none' d='M89.6 57.2v16h50v6M153.6 57.2v16h50v6M217.6 57.2v16h50v6M281.6 57.2v16h50v6M345.6 57.2v16h50v6M409.6 57.2v16h50v6M16 93.2h16v72h6M16 201.2h16v72h6M16 309.2h16v72h6M48 93.2h16v26h6M48 129.2h16v26h6'/>
+ <text dy='0.33em' x='97.6' y='65.2'>0</text>
+ <text dy='0.33em' x='161.6' y='65.2'>1</text>
+ <text dy='0.33em' x='225.6' y='65.2'>2</text>
+ <text dy='0.33em' x='289.6' y='65.2'>3</text>
+ <text dy='0.33em' x='353.6' y='65.2'>4</text>
+ <text dy='0.33em' x='417.6' y='65.2'>5</text>
+ <text dy='0.33em' x='24' y='101.2'>0</text>
+ <text dy='0.33em' x='24' y='209.2'>1</text>
+ <text dy='0.33em' x='24' y='317.2'>2</text>
+ <text dy='0.33em' x='56' y='101.2'>0</text>
+ <text dy='0.33em' x='56' y='137.2'>1</text>
+ </g>
+</svg>
+
<h2 id="rectangles">Rectangles</h2>
<p>A BQN <strong>array</strong> is a multidimensional arrangement of data. The word &quot;array&quot; descends from words meaning &quot;order&quot;, and the data in an array is ordered indeed. Below are examples of arrays with zero, one, and two dimensions.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=PDUKCuKfqDMsJ3gnLDHin6kKCjLigL8z4oC/NCDDl+KMnCAx4oC/NeKAvzjigL8xMQ==">↗️</a><pre> <span class='Function'>&lt;</span><span class='Number'>5</span>