diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-06-21 22:30:52 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-06-21 22:30:52 -0400 |
| commit | 95229afb1ab0e0ef2df3448ab566f834a62907bb (patch) | |
| tree | c55794211c40b427aa0ddf465b49ba87872ff4e4 | |
| parent | 08315d71c8e737694ad21e4d1dd5f1aecbc13560 (diff) | |
Index order diagram
| -rw-r--r-- | doc/reshape.md | 34 | ||||
| -rw-r--r-- | docs/doc/reshape.html | 53 |
2 files changed, 87 insertions, 0 deletions
diff --git a/doc/reshape.md b/doc/reshape.md index 9f96fa26..e9f518d2 100644 --- a/doc/reshape.md +++ b/doc/reshape.md @@ -2,6 +2,40 @@ # Deshape and Reshape +<!--GEN +xt ← Highlight∘•Repr¨ 100‿0‿200+⌜0‿50+⌜↕7 +d ← 64‿36 + +rc ← At "class=code|stroke-width=1.5|rx=12" +Ge ← "g"⊸At⊸Enc +g ← "fill=currentColor|stroke-linecap=round|font-family=BQN,monospace" +dg ← "font-size=22px|fill=currentColor|opacity=0.9" +tg ← "font-size=18px|text-anchor=end" +bg ← "class=bluegreen|stroke-width=3|style=fill:none|opacity=0.7" +lg ← "stroke=#104409|fill=none|stroke-width=4|stroke-linejoin=round|opacity=0.4" + +Text ← ("text" Attr "dy"‿"0.33em"∾Pos)⊸Enc +Pd ← ·∾∾¨⟜FmtNum +Path ← ("path"At⊣) Elt "d"≍○<⊢ + +pad ← 48‿51 ⋄ sh ← 0‿0 +dim ← (pad-0‿7) + ¯1⊑¨ tx‿ty ← pad+d× ¯1(⊑{⟨↕𝕨,⥊+⌜´(↕¨×·×`⌾⌽1+«)𝕩⟩}↓)≢xt +tb ← >0‿¯1⊸⊏¨tx‿ty +cg ← "font-size=19px|text-anchor=middle" +bp ← ⥊⌽(20×1.5‿¯1) (+⌾⊑ ≍ -⊸≍∘⊣)˘ 29‿21-⊸≍⊸+⍉tb + +(((-∾+˜)64‿15)+sh∾dim) SVG g Ge ⟨ + "rect" Elt rc ∾ (Pos sh)∾"width"‿"height"≍˘FmtNum dim + dg Ge 23‿¯2 Text "Index order" + lg Path ∾⟨ + ('M'⌾⊑"L "⥊˜≠)⊸Pd ∾⥊ty≍˜⌜(-⊸≍20)+⊏tb + (≠⥊"M l l "˙)⊸Pd ⥊ 24‿12⊸(-˜∾⊣∾-⌾⊑∘⊣)˘ ⍉>44‿0+0‿2‿5⊸⊏¨tx‿ty + ⟩ + bg Path ("M hv" ∾˜⊸Pd bp) ∾ "m v" Pd 0‿16‿12 + tg Ge (⍉(tx+16)≍⌜ty) Text¨ ∾˝xt +⟩ +--> + The glyph `⥊` indicates BQN's facilities to reflow the data in an array, giving it a different shape. Its monadic form, Deshape, simply removes all shape information, returning a list of all the elements from the array in reading order. With a left argument, `⥊` is called Reshape and is a more versatile tool for rearranging the data in an array into the desired shape. Because of its dependence on the reading order of an array, Reshape is less fundamental than other array operations. Using Reshape in the central computations of a program can be a sign of imperfect usage of arrays. For example, it may be useful to use Reshape to create a constant array or repeat a sequence of values several times, but the same task might also be accomplished more simply with Table `⌜`, or by taking advantage of leading axis agreement in arithmetic primitives. diff --git a/docs/doc/reshape.html b/docs/doc/reshape.html index 597d0390..73c85f83 100644 --- a/docs/doc/reshape.html +++ b/docs/doc/reshape.html @@ -5,6 +5,59 @@ </head> <div class="nav"><a href="https://github.com/mlochbaum/BQN">BQN</a> / <a href="../index.html">main</a> / <a href="index.html">doc</a></div> <h1 id="deshape-and-reshape">Deshape and Reshape</h1> +<svg viewBox='-64 -15 608 377'> + <g fill='currentColor' stroke-linecap='round' font-family='BQN,monospace'> + <rect class='code' stroke-width='1.5' rx='12' x='0' y='0' width='480' height='347'/> + <g font-size='22px' fill='currentColor' opacity='0.9'><text dy='0.33em' x='23' y='-2'>Index order</text></g> + <path stroke='#104409' fill='none' stroke-width='4' stroke-linejoin='round' opacity='0.4' d='M28 51L452 51L28 87L452 87L28 159L452 159L28 195L452 195L28 267L452 267L28 303L452 303M68 39l24 12l-24 12M196 147l24 12l-24 12M388 291l24 12l-24 12'/> + <path class='bluegreen' stroke-width='3' style='fill:none' opacity='0.7' d='M441 324h20v-20M49 30h-30v30m0 16v12'/> + <g font-size='18px' text-anchor='end'> + <text dy='0.33em' x='64' y='51'><tspan class='Number'>100</tspan></text> + <text dy='0.33em' x='128' y='51'><tspan class='Number'>101</tspan></text> + <text dy='0.33em' x='192' y='51'><tspan class='Number'>102</tspan></text> + <text dy='0.33em' x='256' y='51'><tspan class='Number'>103</tspan></text> + <text dy='0.33em' x='320' y='51'><tspan class='Number'>104</tspan></text> + <text dy='0.33em' x='384' y='51'><tspan class='Number'>105</tspan></text> + <text dy='0.33em' x='448' y='51'><tspan class='Number'>106</tspan></text> + <text dy='0.33em' x='64' y='87'><tspan class='Number'>150</tspan></text> + <text dy='0.33em' x='128' y='87'><tspan class='Number'>151</tspan></text> + <text dy='0.33em' x='192' y='87'><tspan class='Number'>152</tspan></text> + <text dy='0.33em' x='256' y='87'><tspan class='Number'>153</tspan></text> + <text dy='0.33em' x='320' y='87'><tspan class='Number'>154</tspan></text> + <text dy='0.33em' x='384' y='87'><tspan class='Number'>155</tspan></text> + <text dy='0.33em' x='448' y='87'><tspan class='Number'>156</tspan></text> + <text dy='0.33em' x='64' y='159'><tspan class='Number'>0</tspan></text> + <text dy='0.33em' x='128' y='159'><tspan class='Number'>1</tspan></text> + <text dy='0.33em' x='192' y='159'><tspan class='Number'>2</tspan></text> + <text dy='0.33em' x='256' y='159'><tspan class='Number'>3</tspan></text> + <text dy='0.33em' x='320' y='159'><tspan class='Number'>4</tspan></text> + <text dy='0.33em' x='384' y='159'><tspan class='Number'>5</tspan></text> + <text dy='0.33em' x='448' y='159'><tspan class='Number'>6</tspan></text> + <text dy='0.33em' x='64' y='195'><tspan class='Number'>50</tspan></text> + <text dy='0.33em' x='128' y='195'><tspan class='Number'>51</tspan></text> + <text dy='0.33em' x='192' y='195'><tspan class='Number'>52</tspan></text> + <text dy='0.33em' x='256' y='195'><tspan class='Number'>53</tspan></text> + <text dy='0.33em' x='320' y='195'><tspan class='Number'>54</tspan></text> + <text dy='0.33em' x='384' y='195'><tspan class='Number'>55</tspan></text> + <text dy='0.33em' x='448' y='195'><tspan class='Number'>56</tspan></text> + <text dy='0.33em' x='64' y='267'><tspan class='Number'>200</tspan></text> + <text dy='0.33em' x='128' y='267'><tspan class='Number'>201</tspan></text> + <text dy='0.33em' x='192' y='267'><tspan class='Number'>202</tspan></text> + <text dy='0.33em' x='256' y='267'><tspan class='Number'>203</tspan></text> + <text dy='0.33em' x='320' y='267'><tspan class='Number'>204</tspan></text> + <text dy='0.33em' x='384' y='267'><tspan class='Number'>205</tspan></text> + <text dy='0.33em' x='448' y='267'><tspan class='Number'>206</tspan></text> + <text dy='0.33em' x='64' y='303'><tspan class='Number'>250</tspan></text> + <text dy='0.33em' x='128' y='303'><tspan class='Number'>251</tspan></text> + <text dy='0.33em' x='192' y='303'><tspan class='Number'>252</tspan></text> + <text dy='0.33em' x='256' y='303'><tspan class='Number'>253</tspan></text> + <text dy='0.33em' x='320' y='303'><tspan class='Number'>254</tspan></text> + <text dy='0.33em' x='384' y='303'><tspan class='Number'>255</tspan></text> + <text dy='0.33em' x='448' y='303'><tspan class='Number'>256</tspan></text> + </g> + </g> +</svg> + <p>The glyph <code><span class='Function'>⥊</span></code> indicates BQN's facilities to reflow the data in an array, giving it a different shape. Its monadic form, Deshape, simply removes all shape information, returning a list of all the elements from the array in reading order. With a left argument, <code><span class='Function'>⥊</span></code> is called Reshape and is a more versatile tool for rearranging the data in an array into the desired shape.</p> <p>Because of its dependence on the reading order of an array, Reshape is less fundamental than other array operations. Using Reshape in the central computations of a program can be a sign of imperfect usage of arrays. For example, it may be useful to use Reshape to create a constant array or repeat a sequence of values several times, but the same task might also be accomplished more simply with Table <code><span class='Modifier'>⌜</span></code>, or by taking advantage of leading axis agreement in arithmetic primitives.</p> <h2 id="deshape">Deshape</h2> |
