aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/tutorial/variable.html20
-rw-r--r--tutorial/variable.md35
2 files changed, 55 insertions, 0 deletions
diff --git a/docs/tutorial/variable.html b/docs/tutorial/variable.html
index 61c425b8..df0d7c74 100644
--- a/docs/tutorial/variable.html
+++ b/docs/tutorial/variable.html
@@ -153,6 +153,26 @@
</table>
<p>Besides using some primitives we haven't seen here, the notation is a little noisy. In return it's very flexible, in that you can apply any function you want, at a location you can select with a large class of BQN functions.</p>
+<svg viewBox='-270 -106 540 212'>
+ <g font-size='20px' text-anchor='middle' fill='currentColor'>
+ <rect class='code' stroke-width='1' rx='12' x='-200' y='-96' width='400' height='192'/>
+ <g stroke-width='3'><path class='purple' style='fill:none' d='M-60 -48l120 0m-15 -8l15 8l-15 8'/></g>
+ <g stroke-width='2'><path class='yellow' style='fill:none' d='M-60 48l120 0m-15 -8l15 8l-15 8M-100 -31.68l0 63.36m8 -15l-8 15l-8 -15M100 -31.68l0 63.36m8 -15l-8 15l-8 -15'/></g>
+ <g font-size='18px' font-family='BQN,monospace'>
+ <text dy='0.31em' x='0' y='-69.12'><tspan class='Function'>-</tspan><tspan class='Modifier2'>⟜</tspan><tspan class='Number'>1</tspan><tspan class='Modifier2'>⌾</tspan><tspan class='Paren'>(</tspan><tspan class='Number'>2</tspan><tspan class='Modifier2'>⊸</tspan><tspan class='Function'>⊑</tspan><tspan class='Paren'>)</tspan></text>
+ <text dy='0.31em' x='0' y='69.12'><tspan class='Function'>-</tspan><tspan class='Modifier2'>⟜</tspan><tspan class='Number'>1</tspan></text>
+ <text dy='0.31em' x='-135' y='0'><tspan class='Number'>2</tspan><tspan class='Modifier2'>⊸</tspan><tspan class='Function'>⊑</tspan></text>
+ <text dy='0.31em' x='135' y='0'><tspan class='Number'>2</tspan><tspan class='Modifier2'>⊸</tspan><tspan class='Function'>⊑</tspan></text>
+ <g class='string'>
+ <text dy='0.31em' x='-100' y='-48'>"BQN"</text>
+ <text dy='0.31em' x='-100' y='48'> 'N' </text>
+ <text dy='0.31em' x='100' y='-48'>"BQM"</text>
+ <text dy='0.31em' x='100' y='48'> 'M' </text>
+ </g>
+ </g>
+ </g>
+</svg>
+
<p>So let's break this down. The 2-modifier Under (<code><span class='Modifier2'>⌾</span></code>) has two operands: the left one, <code><span class='Function'>-</span><span class='Modifier2'>⟜</span><span class='Number'>1</span></code>, subtracts one, and the right one, <code><span class='Number'>2</span><span class='Modifier2'>⊸</span><span class='Function'>⊑</span></code> uses a function we haven't seen before. It uses the right operand to pick out part of its argument, then the left one acts on that part only, and the entire argument, with the necessary modifications, is returned.</p>
<svg viewBox='-174.7 -34 512 188'>
<g font-family='BQN,monospace' font-size='18px' class='Paren' fill='currentColor'>
diff --git a/tutorial/variable.md b/tutorial/variable.md
index 6799cd6d..c9deba12 100644
--- a/tutorial/variable.md
+++ b/tutorial/variable.md
@@ -112,6 +112,41 @@ Primitives ⟨ "⌾%K%Under", "⊑%I%First%Pick" ⟩
-->
Besides using some primitives we haven't seen here, the notation is a little noisy. In return it's very flexible, in that you can apply any function you want, at a location you can select with a large class of BQN functions.
+<!--GEN
+{
+d ← 100‿48
+
+Text ← ("text" Attr "dy"‿"0.31em"∾·Pos d⊸×)⊸Enc
+Path ← ("path" Attr "class"⊸⋈≍"style"‿"fill:none"˙)⊸Elt⟜("d"⊸⋈)
+
+vals ← -⟜1{≍⟜(𝔾¨) ⊢⋈𝔽⌾𝔾}(2⊸⊑) "BQN"
+
+g ← "font-size=20px|text-anchor=middle|fill=currentColor"
+rc ← At "class=code|stroke-width=1|rx=12"
+fc ← "font-size=18px|font-family=BQN,monospace"
+
+Ge ← "g"⊸At⊸Enc
+_arrow ← {
+ a ← ((⊢≍-⌾⊑∘⌽)÷⟜(+´⌾(ט))𝕨) +˝∘×⎉1‿∞˜ 𝕗≍-⌾⊑𝕗
+ ∾"M l m l l "∾¨ FmtNum ∾⥊¨⟨𝕩-𝕨, 𝕨, -⊏a, a⟩
+}
+Arr ← 15‿8 _arrow
+cut ← 0.2‿0.17
+ars ← (×⟜(¬2×cut) Arr○(d⊸×) ×⟜(-cut)⊸+)¨⟜((<-1‿1)⊸++0‿0≍˘⌽) 2×=⟜<↕2
+
+dim ← 5.2‿4×d
+rdim ← 4‿4×d
+(∾÷⟜¯2‿1<20+dim) SVG g Ge ⟨
+ "rect" Elt rc∾(Pos rdim÷¯2)∾"width"‿"height"≍˘FmtNum rdim
+ "stroke-width=3"‿"stroke-width=2" Ge¨ "purple"‿"yellow" Path⟜∾¨ 0‿1‿1‿1⊔⥊ars
+ fc Ge ⟨
+ (⍉-⊸≍1.44‿1.35×⌽<⊸=↕2) Text⟜Highlight¨ "-⟜1⌾(2⊸⊑)"‿"-⟜1"≍⋈˜"2⊸⊑"
+ "class=string" Ge (⋈⌜˜-⟜¬↕2) Text¨ ⍉0‿¯1⌽¨(⌈´∘⥊≠¨)⊸(↑¨) •Repr¨ vals
+ ⟩
+⟩
+}
+-->
+
So let's break this down. The 2-modifier Under (`⌾`) has two operands: the left one, `-⟜1`, subtracts one, and the right one, `2⊸⊑` uses a function we haven't seen before. It uses the right operand to pick out part of its argument, then the left one acts on that part only, and the entire argument, with the necessary modifications, is returned.
<!--GEN evalexp.bqn