diff options
| -rw-r--r-- | doc/selfcmp.md | 37 | ||||
| -rw-r--r-- | docs/doc/selfcmp.html | 126 |
2 files changed, 163 insertions, 0 deletions
diff --git a/doc/selfcmp.md b/doc/selfcmp.md index e17c8c3d..fdb43090 100644 --- a/doc/selfcmp.md +++ b/doc/selfcmp.md @@ -2,6 +2,43 @@ # Self-comparison functions +<!--GEN +d ← 48‿22 + +rc ← At "class=code|stroke-width=1.5|rx=12" +Ge ← "g"⊸At⊸Enc +g ← "font-family=BQN,monospace|font-size=18px|text-anchor=middle" +hg ← "class=purple|stroke-width=0|opacity=0.5" +cg ← "font-size=24px" +lg ← "stroke-width=0.5|stroke=currentColor|fill=none" + +xl ← ≠ xc ← ⊐ xt ← '''(Highlight∾∾⊣)¨"mississippi" +xn ← ≠ xu ← xt /˜ xf ← 0= xo ← ⊒ xt + +Text ← ("text" Attr "dy"‿"0.32em"∾(Pos d⊸×))⊸Enc +Path ← "path" Elt "d"≍○<·∾⊣∾¨·FmtNums(d⊏˜∊⟜" Vv")⊸× +Rp ← Pos⊸∾⟜("width"‿"height"≍˘FmtNum)○(d⊸×) + +tx ← ↕xl ⋄ y ← » yd ← +`0.6+1.2‿1‿xn‿1.8‿1.8 +dim ← ⟨1.5+xl,¯1⊑yd⟩ ⋄ sh ← ¯1.6‿¯1.1 +tp ← (⥊tx≍¨⎉1((¯1↓y)+0‿0‿1‿0×⌜xc))∾(↕≠xu)≍¨¯1⊑y +hp ← 0.2‿¯0.7(+⟜(1‿0×sh)≍¯2⊸×⊸+)1‿0×dim +Pp ← "M VL M H" Path {⟨𝕩,⊑y,0.3+3⊑y,𝕨,0.5-˜4⊑y,𝕩,𝕨+2⊑y,xl-0.6⟩} + +defs ← "defs" Enc ("mask"At"id=m") Enc ⟨ + "rect" Elt "fill"‿"white" ∾ sh Rp dim + "fill=black" Ge ("rect" Elt (- Rp 2×⊢)⟜(7‿10÷d))¨ 0‿0.1⊸+¨⌾(xl⊸↑)tp +⟩ + +((∾˜d)×((-∾+˜)0.8‿0.4)+sh∾dim) SVG defs ∾ g Ge ⟨ + "rect" Elt rc ∾ sh Rp dim + hg Ge ("rect" Elt ·Rp˝ {𝕩⊸+⌾(1⊑⊏)hp})¨ 1‿3⊏y + (lg∾"|mask=url(#m)") Ge (↕≠xu) Pp¨ xf / tx + tp Text¨ xu ∾˜ ⥊ xt ∾ Highlight∘•Repr¨ >xc‿xo‿xf + cg Ge (¯0.05+¯1≍¨(2÷˜xn-1)⊸+⌾(2⊸⊑)y) Text⟜Highlight¨ "𝕩"<⊸∾⥊¨"⊐⊒∊⍷" +⟩ +--> + BQN has four self-comparison functions, Classify (`⊐`), Occurrence Count (`⊒`), Mark Firsts (`∊`), and Deduplicate (`⍷`). Each of these is a monadic function that obtains its result by comparing each major cell of the argument (which must have rank at least 1) to the earlier major cells with [match](match.md). For example, Mark Firsts indicates the cells that don't match any earlier cell, making them the first of their kind. ∊ "abaacb" diff --git a/docs/doc/selfcmp.html b/docs/doc/selfcmp.html index 1374736f..9188c69c 100644 --- a/docs/doc/selfcmp.html +++ b/docs/doc/selfcmp.html @@ -5,6 +5,132 @@ </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="self-comparison-functions">Self-comparison functions</h1> +<svg viewBox='-115.2 -33 676.8 299.2'> + <defs> + <mask id='m'> + <rect fill='white' x='-76.8' y='-24.2' width='600' height='281.6'/> + <g fill='black'> + <rect x='-7' y='-7.8' width='14' height='20'/> + <rect x='41' y='-7.8' width='14' height='20'/> + <rect x='89' y='-7.8' width='14' height='20'/> + <rect x='137' y='-7.8' width='14' height='20'/> + <rect x='185' y='-7.8' width='14' height='20'/> + <rect x='233' y='-7.8' width='14' height='20'/> + <rect x='281' y='-7.8' width='14' height='20'/> + <rect x='329' y='-7.8' width='14' height='20'/> + <rect x='377' y='-7.8' width='14' height='20'/> + <rect x='425' y='-7.8' width='14' height='20'/> + <rect x='473' y='-7.8' width='14' height='20'/> + <rect x='-7' y='29.6' width='14' height='20'/> + <rect x='41' y='29.6' width='14' height='20'/> + <rect x='89' y='29.6' width='14' height='20'/> + <rect x='137' y='29.6' width='14' height='20'/> + <rect x='185' y='29.6' width='14' height='20'/> + <rect x='233' y='29.6' width='14' height='20'/> + <rect x='281' y='29.6' width='14' height='20'/> + <rect x='329' y='29.6' width='14' height='20'/> + <rect x='377' y='29.6' width='14' height='20'/> + <rect x='425' y='29.6' width='14' height='20'/> + <rect x='473' y='29.6' width='14' height='20'/> + <rect x='-7' y='64.8' width='14' height='20'/> + <rect x='41' y='86.8' width='14' height='20'/> + <rect x='89' y='108.8' width='14' height='20'/> + <rect x='137' y='108.8' width='14' height='20'/> + <rect x='185' y='86.8' width='14' height='20'/> + <rect x='233' y='108.8' width='14' height='20'/> + <rect x='281' y='108.8' width='14' height='20'/> + <rect x='329' y='86.8' width='14' height='20'/> + <rect x='377' y='130.8' width='14' height='20'/> + <rect x='425' y='130.8' width='14' height='20'/> + <rect x='473' y='86.8' width='14' height='20'/> + <rect x='-7' y='166' width='14' height='20'/> + <rect x='41' y='166' width='14' height='20'/> + <rect x='89' y='166' width='14' height='20'/> + <rect x='137' y='166' width='14' height='20'/> + <rect x='185' y='166' width='14' height='20'/> + <rect x='233' y='166' width='14' height='20'/> + <rect x='281' y='166' width='14' height='20'/> + <rect x='329' y='166' width='14' height='20'/> + <rect x='377' y='166' width='14' height='20'/> + <rect x='425' y='166' width='14' height='20'/> + <rect x='473' y='166' width='14' height='20'/> + <rect x='-7' y='218.8' width='14' height='20'/> + <rect x='41' y='218.8' width='14' height='20'/> + <rect x='89' y='218.8' width='14' height='20'/> + <rect x='137' y='218.8' width='14' height='20'/> + </g> + </mask> + </defs> + <g font-family='BQN,monospace' font-size='18px' text-anchor='middle'> + <rect class='code' stroke-width='1.5' rx='12' x='-76.8' y='-24.2' width='600' height='281.6'/> + <g class='purple' stroke-width='0' opacity='0.5'> + <rect x='-67.2' y='24.2' width='580.8' height='30.8'/> + <rect x='-67.2' y='160.6' width='580.8' height='30.8'/> + </g> + <g stroke-width='0.5' stroke='currentColor' fill='none' mask='url(#m)'> + <path d='M0 0V182.6L0 217.8M0 74.8H499.2'/> + <path d='M48 0V182.6L48 217.8M48 96.8H499.2'/> + <path d='M96 0V182.6L96 217.8M96 118.8H499.2'/> + <path d='M384 0V182.6L144 217.8M384 140.8H499.2'/> + </g> + <text dy='0.32em' x='0' y='0'><tspan class='String'>'m'</tspan></text> + <text dy='0.32em' x='48' y='0'><tspan class='String'>'i'</tspan></text> + <text dy='0.32em' x='96' y='0'><tspan class='String'>'s'</tspan></text> + <text dy='0.32em' x='144' y='0'><tspan class='String'>'s'</tspan></text> + <text dy='0.32em' x='192' y='0'><tspan class='String'>'i'</tspan></text> + <text dy='0.32em' x='240' y='0'><tspan class='String'>'s'</tspan></text> + <text dy='0.32em' x='288' y='0'><tspan class='String'>'s'</tspan></text> + <text dy='0.32em' x='336' y='0'><tspan class='String'>'i'</tspan></text> + <text dy='0.32em' x='384' y='0'><tspan class='String'>'p'</tspan></text> + <text dy='0.32em' x='432' y='0'><tspan class='String'>'p'</tspan></text> + <text dy='0.32em' x='480' y='0'><tspan class='String'>'i'</tspan></text> + <text dy='0.32em' x='0' y='39.6'><tspan class='Number'>0</tspan></text> + <text dy='0.32em' x='48' y='39.6'><tspan class='Number'>1</tspan></text> + <text dy='0.32em' x='96' y='39.6'><tspan class='Number'>2</tspan></text> + <text dy='0.32em' x='144' y='39.6'><tspan class='Number'>2</tspan></text> + <text dy='0.32em' x='192' y='39.6'><tspan class='Number'>1</tspan></text> + <text dy='0.32em' x='240' y='39.6'><tspan class='Number'>2</tspan></text> + <text dy='0.32em' x='288' y='39.6'><tspan class='Number'>2</tspan></text> + <text dy='0.32em' x='336' y='39.6'><tspan class='Number'>1</tspan></text> + <text dy='0.32em' x='384' y='39.6'><tspan class='Number'>3</tspan></text> + <text dy='0.32em' x='432' y='39.6'><tspan class='Number'>3</tspan></text> + <text dy='0.32em' x='480' y='39.6'><tspan class='Number'>1</tspan></text> + <text dy='0.32em' x='0' y='74.8'><tspan class='Number'>0</tspan></text> + <text dy='0.32em' x='48' y='96.8'><tspan class='Number'>0</tspan></text> + <text dy='0.32em' x='96' y='118.8'><tspan class='Number'>0</tspan></text> + <text dy='0.32em' x='144' y='118.8'><tspan class='Number'>1</tspan></text> + <text dy='0.32em' x='192' y='96.8'><tspan class='Number'>1</tspan></text> + <text dy='0.32em' x='240' y='118.8'><tspan class='Number'>2</tspan></text> + <text dy='0.32em' x='288' y='118.8'><tspan class='Number'>3</tspan></text> + <text dy='0.32em' x='336' y='96.8'><tspan class='Number'>2</tspan></text> + <text dy='0.32em' x='384' y='140.8'><tspan class='Number'>0</tspan></text> + <text dy='0.32em' x='432' y='140.8'><tspan class='Number'>1</tspan></text> + <text dy='0.32em' x='480' y='96.8'><tspan class='Number'>3</tspan></text> + <text dy='0.32em' x='0' y='176'><tspan class='Number'>1</tspan></text> + <text dy='0.32em' x='48' y='176'><tspan class='Number'>1</tspan></text> + <text dy='0.32em' x='96' y='176'><tspan class='Number'>1</tspan></text> + <text dy='0.32em' x='144' y='176'><tspan class='Number'>0</tspan></text> + <text dy='0.32em' x='192' y='176'><tspan class='Number'>0</tspan></text> + <text dy='0.32em' x='240' y='176'><tspan class='Number'>0</tspan></text> + <text dy='0.32em' x='288' y='176'><tspan class='Number'>0</tspan></text> + <text dy='0.32em' x='336' y='176'><tspan class='Number'>0</tspan></text> + <text dy='0.32em' x='384' y='176'><tspan class='Number'>1</tspan></text> + <text dy='0.32em' x='432' y='176'><tspan class='Number'>0</tspan></text> + <text dy='0.32em' x='480' y='176'><tspan class='Number'>0</tspan></text> + <text dy='0.32em' x='0' y='228.8'><tspan class='String'>'m'</tspan></text> + <text dy='0.32em' x='48' y='228.8'><tspan class='String'>'i'</tspan></text> + <text dy='0.32em' x='96' y='228.8'><tspan class='String'>'s'</tspan></text> + <text dy='0.32em' x='144' y='228.8'><tspan class='String'>'p'</tspan></text> + <g font-size='24px'> + <text dy='0.32em' x='-50.4' y='-1.1'><tspan class='Value'>𝕩</tspan></text> + <text dy='0.32em' x='-50.4' y='38.5'><tspan class='Function'>⊐</tspan></text> + <text dy='0.32em' x='-50.4' y='106.7'><tspan class='Function'>⊒</tspan></text> + <text dy='0.32em' x='-50.4' y='174.9'><tspan class='Function'>∊</tspan></text> + <text dy='0.32em' x='-50.4' y='227.7'><tspan class='Function'>⍷</tspan></text> + </g> + </g> +</svg> + <p>BQN has four self-comparison functions, Classify (<code><span class='Function'>⊐</span></code>), Occurrence Count (<code><span class='Function'>⊒</span></code>), Mark Firsts (<code><span class='Function'>∊</span></code>), and Deduplicate (<code><span class='Function'>⍷</span></code>). Each of these is a monadic function that obtains its result by comparing each major cell of the argument (which must have rank at least 1) to the earlier major cells with <a href="match.html">match</a>. For example, Mark Firsts indicates the cells that don't match any earlier cell, making them the first of their kind.</p> <a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oiKICJhYmFhY2Ii">↗️</a><pre> <span class='Function'>∊</span> <span class='String'>"abaacb"</span> ⟨ 1 1 0 0 1 0 ⟩ |
