diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-06-07 22:22:38 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-06-07 22:22:38 -0400 |
| commit | 59f4d13ef3ca09dd17bc561a303aabd2432fbe41 (patch) | |
| tree | 78da866c19dbe47dcd06b72b9a490aa81db16925 | |
| parent | b4959538e555bfa9c21a75269837f34582100a14 (diff) | |
Group graphic
| -rw-r--r-- | doc/group.md | 41 | ||||
| -rw-r--r-- | docs/doc/group.html | 22 |
2 files changed, 63 insertions, 0 deletions
diff --git a/doc/group.md b/doc/group.md index dd5e8da9..946e7256 100644 --- a/doc/group.md +++ b/doc/group.md @@ -4,6 +4,47 @@ BQN replaces the [Key](https://aplwiki.com/wiki/Key) operator from J or Dyalog APL, and [many forms of partitioning](https://aplwiki.com/wiki/Partition_representations), with a single (ambivalent) Group function `⊔`. This function is somewhat related to the K function `=` of the same name, but results in an array rather than a dictionary. +<!--GEN +Num ← ·Highlight •Repr +Str ← ·Highlight '"'(∾∾⊣)⊢ +wf ← Num¨ wv ← 0‿¯1‿¯1‿2‿0 +xf ← Str¨ xv ← "zero"‿"one"‿"two"‿"three"‿"four" +zi ← ↕≠ zf ← wv⊔xf +d ← 80‿28 +Pos ↩ Pos d⊸× +dim ← 7‿7.3 +sh ← 0.6‿0 + +rc ← At "class=code|stroke-width=1|rx=12" +g ← "g"At"text-anchor=middle|font-family=BQN,monospace" +tg ← "g"At"font-size=18px" +cg ← "g"At"text-anchor=end|font-size=16px" +lg ← "g"At"class=yellow|stroke-width=1" +bg ← "g"At"class=green|stroke-width=1|style=fill:none" + +C ← (↕-2÷˜-⟜1)∘≠ +zgp ← (2÷˜»⊸+-⊢´)+`0.6+≠¨zf +zp ← zgp + C¨ zf + +Text ← ("text" Attr Pos)⊸Enc +ty‿txf‿tt ← ⟨ + +`¯2.6‿1‿3‿1.5 + ⟨C, C, ∾zp, zgp⟩ + ⟨wf, xf, ∾zf, Num¨zi⟩ +⟩ +tp ← (tx←txf{𝕎𝕩}¨tt)≍¨¨ty +lp ← (∾wv⊸⊔)⊸(((0.2‿¯0.5×⌜0‿1)+≍)¨)´1‿2⊏tp +b ← (0.4⌈0.2+≠¨zf) {∾"M vhv"∾¨FmtNum (0‿1‿1‿0‿1⊏d)×(⟨𝕨÷¯2,¯2⟩+𝕩)∾⟨1,𝕨,¯1⟩}¨ 3⊑tp + +((∾˜d)×(¯2÷˜sh⊸+)⊸∾1‿0.2+dim) SVG g Enc ⟨ + "rect" Elt rc ∾ (Pos -dim÷2)∾"width"‿"height"≍˘FmtNum d×dim-sh + tg Enc ∾tp Text¨○∾ tt + cg Enc ((¯0.8+⊑⊑tx)≍¨3↑ty) Text⟜Highlight¨ "𝕨"‿"𝕩"‿"𝕨⊔𝕩" + lg Enc (<"xy"≍⌜"12") ("line" Elt ≍˘○⥊)⟜(FmtNum d×⍉)¨ lp + bg Enc ("path" Elt "d"≍○<⊢)¨ b +⟩ +--> + ## Definition Group operates on a list of atomic-number [indices](indices.md) `𝕨` and an array `𝕩`, treated as a list of its major cells, to produce a list of groups, each containing some of the cells from `𝕩`. The two arguments have the same length, and each cell in `𝕩` is paired with the index in `𝕨` at the same position, which indicates which result group should include that cell. diff --git a/docs/doc/group.html b/docs/doc/group.html index 2b03e5fa..c4471132 100644 --- a/docs/doc/group.html +++ b/docs/doc/group.html @@ -6,6 +6,28 @@ <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="group">Group</h1> <p>BQN replaces the <a href="https://aplwiki.com/wiki/Key">Key</a> operator from J or Dyalog APL, and <a href="https://aplwiki.com/wiki/Partition_representations">many forms of partitioning</a>, with a single (ambivalent) Group function <code><span class='Function'>⊔</span></code>. This function is somewhat related to the K function <code><span class='Function'>=</span></code> of the same name, but results in an array rather than a dictionary.</p> +<svg viewBox='-344 -105 640 210'> + <g text-anchor='middle' font-family='BQN,monospace'> + <rect class='code' stroke-width='1' rx='12' x='-280' y='-102.2' width='512' height='204.4'/> + <g font-size='18px'><text x='-160' y='-72.8'><tspan class='Number'>0</tspan></text><text x='-80' y='-72.8'><tspan class='Number'>¯1</tspan></text><text x='0' y='-72.8'><tspan class='Number'>¯1</tspan></text><text x='80' y='-72.8'><tspan class='Number'>2</tspan></text><text x='160' y='-72.8'><tspan class='Number'>0</tspan></text><text x='-160' y='-44.8'><tspan class='String'>"zero"</tspan></text><text x='-80' y='-44.8'><tspan class='String'>"one"</tspan></text><text x='0' y='-44.8'><tspan class='String'>"two"</tspan></text><text x='80' y='-44.8'><tspan class='String'>"three"</tspan></text><text x='160' y='-44.8'><tspan class='String'>"four"</tspan></text><text x='-128' y='39.2'><tspan class='String'>"zero"</tspan></text><text x='-48' y='39.2'><tspan class='String'>"four"</tspan></text><text x='128' y='39.2'><tspan class='String'>"three"</tspan></text><text x='-88' y='81.2'><tspan class='Number'>0</tspan></text><text x='40' y='81.2'><tspan class='Number'>1</tspan></text><text x='128' y='81.2'><tspan class='Number'>2</tspan></text></g> + <g text-anchor='end' font-size='16px'> + <text x='-224' y='-72.8'><tspan class='Value'>𝕨</tspan></text> + <text x='-224' y='-44.8'><tspan class='Value'>𝕩</tspan></text> + <text x='-224' y='39.2'><tspan class='Value'>𝕨</tspan><tspan class='Function'>⊔</tspan><tspan class='Value'>𝕩</tspan></text> + </g> + <g class='yellow' stroke-width='1'> + <line x1='-160' x2='-128' y1='-39.2' y2='25.2'/> + <line x1='160' x2='-48' y1='-39.2' y2='25.2'/> + <line x1='80' x2='128' y1='-39.2' y2='25.2'/> + </g> + <g class='green' stroke-width='1' style='fill:none'> + <path d='M-176 25.2v28h176v-28'/> + <path d='M24 25.2v28h32v-28'/> + <path d='M80 25.2v28h96v-28'/> + </g> + </g> +</svg> + <h2 id="definition">Definition</h2> <p>Group operates on a list of atomic-number <a href="indices.html">indices</a> <code><span class='Value'>𝕨</span></code> and an array <code><span class='Value'>𝕩</span></code>, treated as a list of its major cells, to produce a list of groups, each containing some of the cells from <code><span class='Value'>𝕩</span></code>. The two arguments have the same length, and each cell in <code><span class='Value'>𝕩</span></code> is paired with the index in <code><span class='Value'>𝕨</span></code> at the same position, which indicates which result group should include that cell.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=MOKAvzHigL8y4oC/MOKAvzEg4omNICJhYmNkZSIgICMgQ29ycmVzcG9uZGluZyBpbmRpY2VzIGFuZCB2YWx1ZXMKMOKAvzHigL8y4oC/MOKAvzEg4oqUICJhYmNkZSIgICMgVmFsdWVzIGdyb3VwZWQgYnkgaW5kZXg=">↗️</a><pre> <span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>1</span> <span class='Function'>≍</span> <span class='String'>"abcde"</span> <span class='Comment'># Corresponding indices and values |
