aboutsummaryrefslogtreecommitdiff
path: root/docs/doc/rank.html
blob: 23a5630ebd2bb9810a59c641e06ed2b9edf1bebe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<head>
  <link href="../favicon.ico" rel="shortcut icon" type="image/x-icon"/>
  <link href="../style.css" rel="stylesheet"/>
  <title>BQN: Cells and Rank</title>
</head>
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">doc</a></div>
<h1 id="cells-and-rank"><a class="header" href="#cells-and-rank">Cells and Rank</a></h1>
<svg viewBox='-13.8 -12 506 240'>
  <g font-size='18px' fill='currentColor' font-family='BQN,monospace' text-anchor='middle'>
    <rect class='code' stroke-width='1.5' rx='12' x='0' y='0' width='478.4' height='216'/>
    <g font-size='24px' fill='currentColor' opacity='0.9' text-anchor='start'><text dy='0.33em' x='9.2' y='0'>Cells</text></g>
    <g transform='translate(55.2,96)'>
      <g stroke-width='0.3' fill='none' stroke='currentColor'>
        <rect x='-11' y='-11' width='160' height='22'/>
        <rect x='-11' y='29' width='160' height='22'/>
        <rect x='-11' y='69' width='160' height='22'/>
      </g>
      <text dy='0.33em' x='0' y='0'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='46' y='0'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='92' y='0'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='138' y='0'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='0' y='40'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='46' y='40'><tspan class='Number'>1</tspan></text>
      <text dy='0.33em' x='92' y='40'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='138' y='40'><tspan class='Number'>5</tspan></text>
      <text dy='0.33em' x='0' y='80'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='46' y='80'><tspan class='Number'>2</tspan></text>
      <text dy='0.33em' x='92' y='80'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='138' y='80'><tspan class='Number'>0</tspan></text>
      <path class='bluegreen' stroke-width='2' stroke-linecap='round' style='fill:none' opacity='0.7' d='M142 99h15v-15M3.5 -19h-22.5v22.5'/>
      <rect stroke-width='0.3' fill='none' stroke='currentColor' x='-11' y='-55' width='160' height='22'/>
      <path class='green' stroke-width='3' stroke-linecap='round' opacity='0.2' d='M101.2 92v-76h23l-55.2 -56l-55.2 56h23v76z'/>
      <g font-size='24px' text-anchor='start'><text dy='0.33em' x='-46' y='-44'><tspan class='Function'>+</tspan><tspan class='Modifier'>˝</tspan></text></g>
      <text dy='0.33em' x='0' y='-44'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='46' y='-44'><tspan class='Number'>3</tspan></text>
      <text dy='0.33em' x='92' y='-44'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='138' y='-44'><tspan class='Number'>5</tspan></text>
      <g font-size='24px'>
        <text dy='0.33em' x='69' y='20'><tspan class='Function'>+</tspan></text>
        <text dy='0.33em' x='69' y='60'><tspan class='Function'>+</tspan></text>
      </g>
    </g>
    <g transform='translate(308.2,96)'>
      <g stroke-width='0.3' fill='none' stroke='currentColor'>
        <rect x='-11' y='-11' width='160' height='22'/>
        <rect x='-11' y='29' width='160' height='22'/>
        <rect x='-11' y='69' width='160' height='22'/>
      </g>
      <text dy='0.33em' x='0' y='0'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='46' y='0'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='92' y='0'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='138' y='0'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='0' y='40'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='46' y='40'><tspan class='Number'>1</tspan></text>
      <text dy='0.33em' x='92' y='40'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='138' y='40'><tspan class='Number'>5</tspan></text>
      <text dy='0.33em' x='0' y='80'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='46' y='80'><tspan class='Number'>2</tspan></text>
      <text dy='0.33em' x='92' y='80'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='138' y='80'><tspan class='Number'>0</tspan></text>
      <path class='bluegreen' stroke-width='2' stroke-linecap='round' style='fill:none' opacity='0.7' d='M142 99h15v-15M3.5 -19h-22.5v22.5'/>
      <g stroke-width='0.3' fill='none' stroke='currentColor'>
        <rect x='-57' y='-11' width='22' height='22'/>
        <rect x='-57' y='29' width='22' height='22'/>
        <rect x='-57' y='69' width='22' height='22'/>
      </g>
      <g class='green' stroke-width='3' stroke-linecap='round' opacity='0.2' style='fill:none'>
        <path d='M147.2 0l-184 0m15 8l-15 -8l15 -8'/>
        <path d='M147.2 40l-184 0m15 8l-15 -8l15 -8'/>
        <path d='M147.2 80l-184 0m15 8l-15 -8l15 -8'/>
      </g>
      <g font-size='24px' text-anchor='start'><text dy='0.33em' x='-55.2' y='-44'><tspan class='Function'>+</tspan><tspan class='Modifier'>˝˘</tspan></text></g>
      <text dy='0.33em' x='-46' y='0'><tspan class='Number'>0</tspan></text>
      <text dy='0.33em' x='-46' y='40'><tspan class='Number'>6</tspan></text>
      <text dy='0.33em' x='-46' y='80'><tspan class='Number'>2</tspan></text>
      <text dy='0.33em' x='23' y='0'><tspan class='Function'>+</tspan></text>
      <text dy='0.33em' x='69' y='0'><tspan class='Function'>+</tspan></text>
      <text dy='0.33em' x='115' y='0'><tspan class='Function'>+</tspan></text>
      <text dy='0.33em' x='23' y='40'><tspan class='Function'>+</tspan></text>
      <text dy='0.33em' x='69' y='40'><tspan class='Function'>+</tspan></text>
      <text dy='0.33em' x='115' y='40'><tspan class='Function'>+</tspan></text>
      <text dy='0.33em' x='23' y='80'><tspan class='Function'>+</tspan></text>
      <text dy='0.33em' x='69' y='80'><tspan class='Function'>+</tspan></text>
      <text dy='0.33em' x='115' y='80'><tspan class='Function'>+</tspan></text>
    </g>
  </g>
</svg>

<p>The Cells modifier <code><span class='Modifier'>˘</span></code> applies a function to major cells of its argument, much like <a href="map.html">Each</a> applies to elements. Each result from <code><span class='Function'>𝔽</span></code> becomes a major cell of the result, which means they must all have the same shape.</p>
<p>The Rank modifier <code><span class='Modifier2'></span></code> generalizes this concept by allowing numbers provided by <code><span class='Function'>𝔾</span></code> to specify a rank for each argument: non-negative to indicate the rank of each array passed to <code><span class='Function'>𝔽</span></code>, or negative for the number of axes that are mapped over. Cells, which maps over one axis of each argument, is identical to <code><span class='Modifier2'></span><span class='Number'>¯1</span></code>. Rank is analogous to the <a href="depth.html#the-depth-modifier">Depth modifier</a>, but the homogeneous structure of an array eliminates some tricky edge cases found in Depth.</p>
<h2 id="cells"><a class="header" href="#cells">Cells</a></h2>
<p>The function Cells (<code><span class='Modifier'>˘</span></code>) is named after <em>major cells</em> in an array. A <a href="array.html#cells">major cell</a> is a component of an array with dimension one smaller, so that the major cells of a list are <a href="enclose.html#whats-a-unit">units</a>, the major cells of a rank-2 table are its rows (which are lists), and the major cells of a rank-3 array are tables.</p>
<p>The function <code><span class='Function'>𝔽</span><span class='Modifier'>˘</span></code> applies <code><span class='Function'>𝔽</span></code> to the major cells of <code><span class='Value'>𝕩</span></code>. So, for example, where <a href="shift.html">Nudge</a> (<code><span class='Function'>»</span></code>) shifts an entire table, Nudge Cells shifts its major cells, or rows.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=YSDihpAgJ2EnICsgM+KAv+KImCDipYog4oaVMjQgICMgQSBjaGFyYWN0ZXIgYXJyYXkKCuKfqCAgYSAgICAgICwgICAgIMK7YSAgICAgLCAgICDCu8uYYSDin6k=">↗️</a><pre>    <span class='Value'>a</span> <span class='Gets'></span> <span class='String'>'a'</span> <span class='Function'>+</span> <span class='Number'>3</span><span class='Ligature'></span><span class='Modifier2'></span> <span class='Function'></span> <span class='Function'></span><span class='Number'>24</span>  <span class='Comment'># A character array
</span>
    <span class='Bracket'></span>  <span class='Value'>a</span>      <span class='Separator'>,</span>     <span class='Function'>»</span><span class='Value'>a</span>     <span class='Separator'>,</span>    <span class='Function'>»</span><span class='Modifier'>˘</span><span class='Value'>a</span> <span class='Bracket'></span>
┌─                                        
· ┌─           ┌─           ┌─            
  ╵"abcdefgh   ╵"           ╵" abcdefg    
    ijklmnop     abcdefgh      ijklmno    
    qrstuvwx"    ijklmnop"     qrstuvw"   
             ┘            ┘            ┘  
                                         ┘
</pre>
<p>What's it mean for Nudge to shift the &quot;entire table&quot;? The block above shows that it shifts downward, but what's really happening is that Nudge treats <code><span class='Value'>𝕩</span></code> as a collection of major cells—its rows—and shifts these. So it adds an entire row and moves the rest of the rows downwards. Nudge Cells appears similar, but it's acting independently on each row, and the values that it moves around are major cells of the row, that is, rank-0 units.</p>
<p>Here's an example showing how Cells can be used to shift each row independently, even though it's not possible to shift columns like this (in fact the best way to do that would be to <a href="transpose.html">transpose</a> in order to work on rows). It uses the not-yet-introduced dyadic form of Cells, so you might want to come back to it after reading the next section.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KOKGkSLiiJjiiJgiKSDiipHiirjCu8uYIGE=">↗️</a><pre>    <span class='Paren'>(</span><span class='Function'></span><span class='String'>&quot;∘∘&quot;</span><span class='Paren'>)</span> <span class='Function'></span><span class='Modifier2'></span><span class='Function'>»</span><span class='Modifier'>˘</span> <span class='Value'>a</span>
┌─          
╵"abcdefgh  
  ∘ijklmno  
  ∘∘qrstuv" 
           ┘
</pre>
<p>You can also see how Cells splits its argument into rows using a less array-oriented primitive: <a href="enclose.html">Enclose</a> just wraps each row up so that it appears as a separate element in the final result.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=PMuYIGE=">↗️</a><pre>    <span class='Function'>&lt;</span><span class='Modifier'>˘</span> <span class='Value'>a</span>
⟨ "abcdefgh" "ijklmnop" "qrstuvwx" ⟩
</pre>
<p>Enclose also comes in handy for the following task: join the rows in an array of lists, resulting in an array where each element is a joined row. The obvious guess would be &quot;join cells&quot;, <code><span class='Function'></span><span class='Modifier'>˘</span></code>, but it doesn't work, because each <code><span class='Function'></span></code> can return a result with a different length. Cells tries to make each result of <code><span class='Function'></span></code> into a <em>cell</em>, when the problem was to use it as an <em>element</em>. But a 0-cell is an enclosed element, so we can close the gap by applying <code><span class='Function'>&lt;</span></code> to a joined list: <code><span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Function'></span></code>.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqiIHMg4oaQICJ3b3JkcyLigL8iZ28i4oC/ImhlcmUiIOKJjSAic29tZSLigL8ib3RoZXIi4oC/IndvcmRzIgoK4oi+y5ggcwoKPOKImOKIvsuYIHM=">↗️</a><pre>    <span class='Function'></span> <span class='Value'>s</span> <span class='Gets'></span> <span class='String'>&quot;words&quot;</span><span class='Ligature'></span><span class='String'>&quot;go&quot;</span><span class='Ligature'></span><span class='String'>&quot;here&quot;</span> <span class='Function'></span> <span class='String'>&quot;some&quot;</span><span class='Ligature'></span><span class='String'>&quot;other&quot;</span><span class='Ligature'></span><span class='String'>&quot;words&quot;</span>
┌─                         
╵ "words" "go"    "here"   
  "some"  "other" "words"  
                          ┘

    <span class='Function'></span><span class='Modifier'>˘</span> <span class='Value'>s</span>
<span class='Error'>Error: >: Elements didn't have equal shapes (contained shapes ⟨11⟩ and ⟨14⟩)</span>

    <span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Function'></span><span class='Modifier'>˘</span> <span class='Value'>s</span>
⟨ "wordsgohere" "someotherwords" ⟩
</pre>
<p>This approach can apply to more complicated functions as well. And because the result of <code><span class='Function'>&lt;</span></code> always has the same shape, <code><span class='Bracket'>⟨⟩</span></code>, the function <code><span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Function'>𝔽</span><span class='Modifier'>˘</span></code> can never have a shape agreement error. So if <code><span class='Function'>𝔽</span><span class='Modifier'>˘</span></code> fails, it can't hurt to check <code><span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Function'>𝔽</span><span class='Modifier'>˘</span></code> and see what results <code><span class='Function'>𝔽</span></code> is returning.</p>
<h3 id="two-arguments"><a class="header" href="#two-arguments">Two arguments</a></h3>
<p>When given two arguments, Cells tries to pair their cells together. Starting simple, a unit (whether array or atom) on either side will be paired with every cell of the other argument.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=J+KImCcgwrvLmCBh">↗️</a><pre>    <span class='String'>'∘'</span> <span class='Function'>»</span><span class='Modifier'>˘</span> <span class='Value'>a</span>
┌─          
╵"∘abcdefg  
  ∘ijklmno  
  ∘qrstuvw" 
           ┘
</pre>
<p>If you <em>want</em> to use this one-to-many behavior with an array, it'll take more work: since you're really only mapping over one argument, <a href="hook.html">bind</a> the other inside Cells.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=IuKImOKImCIgwrvLmCBhCgoi4oiY4oiYIuKKuMK7y5ggYQ==">↗️</a><pre>    <span class='String'>&quot;∘∘&quot;</span> <span class='Function'>»</span><span class='Modifier'>˘</span> <span class='Value'>a</span>
<span class='Error'>Error: ˘: Leading axis of arguments not equal (⟨2⟩ ≡ ≢𝕨, 3‿8 ≡ ≢𝕩)</span>

    <span class='String'>&quot;∘∘&quot;</span><span class='Modifier2'></span><span class='Function'>»</span><span class='Modifier'>˘</span> <span class='Value'>a</span>
┌─          
╵"∘∘abcdef  
  ∘∘ijklmn  
  ∘∘qrstuv" 
           ┘
</pre>
<p>This is because the general case of Cells does one-to-one matching, pairing the first axis of one argument with the other. For this to work, the two arguments need to have the same length.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4p+oICIwMTIiIMK7y5ggYSwgICgz4oC/4oiY4qWKIlVWV1hZWiIpIMK7y5ggYSDin6k=">↗️</a><pre>    <span class='Bracket'></span> <span class='String'>&quot;012&quot;</span> <span class='Function'>»</span><span class='Modifier'>˘</span> <span class='Value'>a</span><span class='Separator'>,</span>  <span class='Paren'>(</span><span class='Number'>3</span><span class='Ligature'></span><span class='Modifier2'></span><span class='Function'></span><span class='String'>&quot;UVWXYZ&quot;</span><span class='Paren'>)</span> <span class='Function'>»</span><span class='Modifier'>˘</span> <span class='Value'>a</span> <span class='Bracket'></span>
┌─                           
· ┌─           ┌─            
  ╵"0abcdefg   ╵"UVabcdef    
    1ijklmno     WXijklmn    
    2qrstuvw"    YZqrstuv"   
             ┘            ┘  
                            ┘
</pre>
<p>The arguments might have different ranks: for example, <code><span class='String'>&quot;012&quot;</span></code> has rank 1 and <code><span class='Value'>a</span></code> has rank 2 above. That's fine: it just means Cells will pass arguments of rank 0 and 1 to its operand. You can see these arguments using <a href="pair.html">Pair</a> Cells, <code><span class='Function'></span><span class='Modifier'>˘</span></code>, so that each cell of the result is just a list of the two arguments used for that call.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=IjAxMiIg4ouIy5ggYQ==">↗️</a><pre>    <span class='String'>&quot;012&quot;</span> <span class='Function'></span><span class='Modifier'>˘</span> <span class='Value'>a</span>
┌─                  
╵ ┌·    "abcdefgh"  
  ·'0'              
      ┘             
  ┌·    "ijklmnop"  
  ·'1'              
      ┘             
  ┌·    "qrstuvwx"  
  ·'2'              
      ┘             
                   ┘
</pre>
<h2 id="rank"><a class="header" href="#rank">Rank</a></h2>
<p>Rank (<code><span class='Modifier2'></span></code>) is a generalization of Cells (<code><span class='Function'>𝔽</span><span class='Modifier'>˘</span></code> is defined to be <code><span class='Function'>𝔽</span><span class='Modifier2'></span><span class='Number'>¯1</span></code>) that can apply to arbitrary—not just major—<a href="array.html#cells">cells</a> and combine different levels of mapping for two arguments.</p>
<p>Rank comes in handy when there are high-rank arrays with lots of exciting axes, which is a great use case for BQN but honestly isn't all that common. And to continue this trend of honesty, using Rank just never <em>feels</em> good—it's some heavy machinery that I drag out when nothing else works, only to make use of a small part of the functionality. If Cells covers your use cases, that's probably for the best!</p>
<h3 id="negative-and-positive-ranks"><a class="header" href="#negative-and-positive-ranks">Negative and positive ranks</a></h3>
<p>I've said that <code><span class='Function'>𝔽</span><span class='Modifier2'></span><span class='Number'>¯1</span></code> is <code><span class='Function'>𝔽</span><span class='Modifier'>˘</span></code>. And it's also the case that <code><span class='Function'>𝔽</span><span class='Modifier2'></span><span class='Number'>¯2</span></code> is <code><span class='Function'>𝔽</span><span class='Modifier'>˘˘</span></code>. And <code><span class='Function'>𝔽</span><span class='Modifier2'></span><span class='Number'>¯3</span></code> is <code><span class='Function'>𝔽</span><span class='Modifier'>˘˘˘</span></code>. And so on.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KOKGlTQpICjii4jLmMuYy5gg4omhIOKLiOKOicKvMykg4oaVNOKAvzLigL8y4oC/NQ==">↗️</a><pre>    <span class='Paren'>(</span><span class='Function'></span><span class='Number'>4</span><span class='Paren'>)</span> <span class='Paren'>(</span><span class='Function'></span><span class='Modifier'>˘˘˘</span> <span class='Function'></span> <span class='Function'></span><span class='Modifier2'></span><span class='Number'>¯3</span><span class='Paren'>)</span> <span class='Function'></span><span class='Number'>4</span><span class='Ligature'></span><span class='Number'>2</span><span class='Ligature'></span><span class='Number'>2</span><span class='Ligature'></span><span class='Number'>5</span>
1
</pre>
<p>So <code><span class='Function'>𝔽</span><span class='Modifier2'></span><span class='Paren'>(</span><span class='Function'>-</span><span class='Value'>k</span><span class='Paren'>)</span></code>, at least for <code><span class='Value'>k</span><span class='Function'></span><span class='Number'>1</span></code>, is how you map over the first <code><span class='Value'>k</span></code> axes of an array or two. We'll get more into why this is in the next section. What about some positivity for a change?</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=POKOiTAgImFiYyLiiY0iZGVmIgoKPOKOiTEgImFiYyLiiY0iZGVmIg==">↗️</a><pre>    <span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Number'>0</span> <span class='String'>&quot;abc&quot;</span><span class='Function'></span><span class='String'>&quot;def&quot;</span>
┌─                   
╵ ┌·    ┌·    ┌·     
  ·'a'  ·'b'  ·'c'   
      ┘     ┘     ┘  
  ┌·    ┌·    ┌·     
  ·'d'  ·'e'  ·'f'   
      ┘     ┘     ┘  
                    ┘

    <span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Number'>1</span> <span class='String'>&quot;abc&quot;</span><span class='Function'></span><span class='String'>&quot;def&quot;</span>
⟨ "abc" "def" ⟩
</pre>
<p>The function <code><span class='Function'>𝔽</span><span class='Modifier2'></span><span class='Value'>k</span></code>, for <code><span class='Value'>k</span><span class='Function'></span><span class='Number'>0</span></code>, operates on the <code><span class='Value'>k</span></code>-cells of its arguments—that is, it maps over all <em>but</em> the last <code><span class='Value'>k</span></code> axes. For any given argument <code><span class='Value'>a</span></code>, ranks <code><span class='Value'>k</span></code> and <code><span class='Value'>k</span><span class='Function'>-=</span><span class='Value'>a</span></code> are the same, as long as <code><span class='Value'>k</span><span class='Function'></span><span class='Number'>0</span></code> and <code><span class='Paren'>(</span><span class='Value'>k</span><span class='Function'>-=</span><span class='Value'>a</span><span class='Paren'>)</span><span class='Function'></span><span class='Number'>¯1</span></code>. So rank 2 is rank ¯3 for a rank-5 array. The reason this option is useful is that the same rank might be applied to multiple arguments, either with multiple function calls or one call on two arguments. Let's revisit an example with Cells from before, shifting the same string into each row of a table. The function <code><span class='Function'>»</span></code> should be called on rank-1 strings, but because the argument ranks are different, a negative rank can't get down to rank 1 on both sides. Positive rank 1 does the job, allowing us to unbundle the string <code><span class='String'>&quot;∘∘&quot;</span></code> so that <code><span class='Function'>»</span><span class='Modifier2'></span><span class='Number'>1</span></code> is a standalone function.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=IuKImOKImCLiirjCu8uYIGEKCiLiiJjiiJgiIMK74o6JMSBh">↗️</a><pre>    <span class='String'>&quot;∘∘&quot;</span><span class='Modifier2'></span><span class='Function'>»</span><span class='Modifier'>˘</span> <span class='Value'>a</span>
┌─          
╵"∘∘abcdef  
  ∘∘ijklmn  
  ∘∘qrstuv" 
           ┘

    <span class='String'>&quot;∘∘&quot;</span> <span class='Function'>»</span><span class='Modifier2'></span><span class='Number'>1</span> <span class='Value'>a</span>
┌─          
╵"∘∘abcdef  
  ∘∘ijklmn  
  ∘∘qrstuv" 
           ┘
</pre>
<p>The rank for a given argument is clamped, so that on a rank 3 argument for example, a rank of ¯5 counts as ¯3 and a rank of 6 counts as 3 (same for any other value less than ¯3 or greater than 3, although it does have to be a whole number). You may have noticed there's <a href="../commentary/problems.html#rankdepth-negative-zero">no</a> option for ¯0, &quot;don't map over anything&quot;, but ∞ serves that purpose, as it indicates the highest possible rank and thus the entire array. More on why that's useful later.</p>
<h3 id="frame-and-cells"><a class="header" href="#frame-and-cells">Frame and Cells</a></h3>
<p>Lets look at things more systematically. Suppose <code><span class='Value'>x</span></code> has shape <code><span class='Number'>4</span><span class='Ligature'></span><span class='Number'>3</span><span class='Ligature'></span><span class='Number'>2</span><span class='Ligature'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'>0</span></code>, and we'd like to approach it with <code><span class='Modifier2'></span><span class='Number'>2</span></code>, or equivalently <code><span class='Modifier2'></span><span class='Number'>¯3</span></code>. This choice splits the axes of <code><span class='Value'>x</span></code> into two parts: leading axes (shapes <code><span class='Number'>4</span><span class='Ligature'></span><span class='Number'>3</span><span class='Ligature'></span><span class='Number'>2</span></code>) make up the <em>frame</em> of <code><span class='Value'>x</span></code>, while trailing axes give the shape <code><span class='Number'>1</span><span class='Ligature'></span><span class='Number'>0</span></code> of each <em>cell</em> of <code><span class='Value'>x</span></code>.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4omiICAgPOKOiTIg4oaVNOKAvzPigL8y4oC/MeKAvzAKCuKJoiDiipEgPOKOiTIg4oaVNOKAvzPigL8y4oC/MeKAvzA=">↗️</a><pre>    <span class='Function'></span>   <span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Number'>2</span> <span class='Function'></span><span class='Number'>4</span><span class='Ligature'></span><span class='Number'>3</span><span class='Ligature'></span><span class='Number'>2</span><span class='Ligature'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'>0</span>
⟨ 4 3 2 ⟩

    <span class='Function'></span> <span class='Function'></span> <span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Number'>2</span> <span class='Function'></span><span class='Number'>4</span><span class='Ligature'></span><span class='Number'>3</span><span class='Ligature'></span><span class='Number'>2</span><span class='Ligature'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'>0</span>
⟨ 1 0 ⟩
</pre>
<p>We can build a frame array using <code><span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Number'>2</span></code>, as shown above. In the general case, the frame remains conceptual: the actual array <code><span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Number'>2</span> <span class='Value'>x</span></code> is never created, and the result might also not have the shape <code><span class='Number'>4</span><span class='Ligature'></span><span class='Number'>3</span><span class='Ligature'></span><span class='Number'>2</span></code>. But the result shape does always have <code><span class='Number'>4</span><span class='Ligature'></span><span class='Number'>3</span><span class='Ligature'></span><span class='Number'>2</span></code> as a prefix. Rank maps over these axes, leaving them intact. And it can be defined in terms of the cell-splitting function <code><span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Value'>k</span></code>, and its inverse <a href="couple.html#merge-and-array-theory">Merge</a> (<code><span class='Function'>&gt;</span></code>).</p>
<pre><span class='Function'>F</span><span class='Modifier2'></span><span class='Value'>k</span> <span class='Value'>x</span>  <span class='Gets'>←→</span>  <span class='Function'>&gt;F</span><span class='Modifier'>¨</span><span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Value'>k</span> <span class='Value'>x</span>
</pre>
<p>That is, <code><span class='Function'>F</span><span class='Modifier2'></span><span class='Value'>k</span></code> splits its argument into <code><span class='Value'>k</span></code>-cells, applies <code><span class='Function'>F</span></code> to each of these (in index order, of course), then merges the results into a single array.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=K8ud4o6JMSA04oC/MuKliuKGlTgKCivLncKoPOKOiTEgNOKAvzLipYrihpU4ICAjICvLnSBvZiBhIGxpc3QgaXMgYSB1bml0Cgo+K8udwqg84o6JMSA04oC/MuKliuKGlTg=">↗️</a><pre>    <span class='Function'>+</span><span class='Modifier'>˝</span><span class='Modifier2'></span><span class='Number'>1</span> <span class='Number'>4</span><span class='Ligature'></span><span class='Number'>2</span><span class='Function'>⥊↕</span><span class='Number'>8</span>
⟨ 1 5 9 13 ⟩

    <span class='Function'>+</span><span class='Modifier'>˝¨</span><span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Number'>1</span> <span class='Number'>4</span><span class='Ligature'></span><span class='Number'>2</span><span class='Function'>⥊↕</span><span class='Number'>8</span>  <span class='Comment'># +˝ of a list is a unit
</span>┌─                          
· ┌·    ┌·    ┌·    ┌·      
  · 1   · 5   · 9   · 13    
      ┘     ┘     ┘      ┘  
                           ┘

    <span class='Function'>&gt;+</span><span class='Modifier'>˝¨</span><span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Number'>1</span> <span class='Number'>4</span><span class='Ligature'></span><span class='Number'>2</span><span class='Function'>⥊↕</span><span class='Number'>8</span>
⟨ 1 5 9 13 ⟩
</pre>
<p>Each can be implemented by acting on 0-cells with Rank too: <code><span class='Function'>F</span><span class='Modifier2'></span><span class='Function'></span><span class='Modifier2'></span><span class='Number'>0</span> <span class='Value'>x</span> <span class='Gets'>←→</span> <span class='Function'>F</span><span class='Modifier'>¨</span><span class='Value'>x</span></code>, meaning that <code><span class='Function'>F</span><span class='Modifier'>¨</span></code> applies <code><span class='Function'>F</span></code> to the interior of each 0-cell, that is, each element. Some half-way identities are <code><span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Function'>F</span><span class='Modifier2'></span><span class='Value'>k</span>  <span class='Gets'>←→</span> <span class='Function'>F</span><span class='Modifier'>¨</span><span class='Function'>&lt;</span><span class='Modifier2'></span><span class='Value'>k</span></code> and <code><span class='Function'>F</span><span class='Modifier2'></span><span class='Function'></span><span class='Modifier2'></span><span class='Number'>0</span> <span class='Gets'>←→</span> <span class='Function'>&gt;F</span><span class='Modifier'>¨</span></code>.</p>
<h3 id="multiple-and-computed-ranks"><a class="header" href="#multiple-and-computed-ranks">Multiple and computed ranks</a></h3>
<p>The Rank modifier also accepts a list of one to three numbers for <code><span class='Value'>𝕘</span></code>, as well as a function <code><span class='Function'>𝔾</span></code> returning such a list. Practically speaking, here's what you need to know:</p>
<ul>
<li>A single number or one-element list indicates the ranks for all arguments.</li>
<li>Two numbers indicate the ranks for <code><span class='Value'>𝕨</span></code> and <code><span class='Value'>𝕩</span></code>.</li>
</ul>
<p>As an example, we'll define the matrix-vector product. A matrix is a rank-2 array and a vector is a list, and their product is a list. It's made up of the elements <code><span class='Function'>+</span><span class='Modifier'>´</span> <span class='Value'>row</span> <span class='Function'>×</span> <span class='Value'>vec</span></code> for each row <code><span class='Value'>row</span></code> of the matrix. To define this using Rank, we'll change <code><span class='Function'>+</span><span class='Modifier'>´</span></code> to <code><span class='Function'>+</span><span class='Modifier'>˝</span></code> to get a unit out, and we need to map over the rows of the left argument but not of the right one. Following the rules above, there are several ways to do this, including <code><span class='Function'>+</span><span class='Modifier'>˝</span><span class='Modifier2'></span><span class='Function'>×</span><span class='Modifier2'></span><span class='Number'>1</span></code>, <code><span class='Function'>+</span><span class='Modifier'>˝</span><span class='Modifier2'></span><span class='Function'>×</span><span class='Modifier2'></span><span class='Number'>¯1</span><span class='Ligature'></span><span class='Number'>1</span></code>, and <code><span class='Function'>+</span><span class='Modifier'>˝</span><span class='Modifier2'></span><span class='Function'>×</span><span class='Modifier2'></span><span class='Number'>¯1</span><span class='Ligature'></span><span class='Number'></span></code>. Note that <code><span class='Modifier2'></span><span class='Number'>¯1</span></code> wouldn't work, because the ¯1 is interpreted separately for both arguments—it's equivalent to 1 matrix but 0 for the vector, or <code><span class='Modifier2'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'>0</span></code> overall. for the  When correctly defined we can see that multiplication by the matrix <code><span class='Value'>m</span></code> below negates the first element of a list, and also swaps it with the second.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqiIG0g4oaQID7in6gw4oC/MeKAvzAswq8x4oC/MOKAvzAsMOKAvzDigL8x4p+pCgory50gMOKAvzHigL8wIMOXIDHigL8y4oC/MwoKbSAry53iiJjDl+KOiTHigL/iiJ4gMeKAvzLigL8z">↗️</a><pre>    <span class='Function'></span> <span class='Value'>m</span> <span class='Gets'></span> <span class='Function'>&gt;</span><span class='Bracket'></span><span class='Number'>0</span><span class='Ligature'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'>0</span><span class='Separator'>,</span><span class='Number'>¯1</span><span class='Ligature'></span><span class='Number'>0</span><span class='Ligature'></span><span class='Number'>0</span><span class='Separator'>,</span><span class='Number'>0</span><span class='Ligature'></span><span class='Number'>0</span><span class='Ligature'></span><span class='Number'>1</span><span class='Bracket'></span>
┌─        
╵  0 1 0  
  ¯1 0 0  
   0 0 1  
         ┘

    <span class='Function'>+</span><span class='Modifier'>˝</span> <span class='Number'>0</span><span class='Ligature'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'>0</span> <span class='Function'>×</span> <span class='Number'>1</span><span class='Ligature'></span><span class='Number'>2</span><span class='Ligature'></span><span class='Number'>3</span>
┌·   
· 2  
    ┘

    <span class='Value'>m</span> <span class='Function'>+</span><span class='Modifier'>˝</span><span class='Modifier2'></span><span class='Function'>×</span><span class='Modifier2'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'></span> <span class='Number'>1</span><span class='Ligature'></span><span class='Number'>2</span><span class='Ligature'></span><span class='Number'>3</span>
⟨ 2 ¯1 3 ⟩
</pre>
<p>But a rank of <code><span class='Number'>1</span><span class='Ligature'></span><span class='Number'></span></code> works the best because it also defines a matrix-<em>matrix</em> product. Which as shown below does the same transformation to the <em>cells</em> of the right-hand-side matrix, instead of the elements of a vector. This works because <code><span class='Function'>×</span></code> and <code><span class='Function'>+</span><span class='Modifier'>˝</span></code> work on the leading axes of their arguments. When <code><span class='Modifier2'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'></span></code> is applied, these axes are the last axis of <code><span class='Value'>𝕨</span></code> and the first axis of <code><span class='Value'>𝕩</span></code>. Which… is kind of weird, but it's what a matrix product is.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=K8udIDDigL8x4oC/MCDDlyAx4oC/MuKAvzPDl+KMnDHigL8xMAoKbSAry53iiJjDl+KOiTHigL/iiJ4gMeKAvzLigL8zw5fijJwx4oC/MTA=">↗️</a><pre>    <span class='Function'>+</span><span class='Modifier'>˝</span> <span class='Number'>0</span><span class='Ligature'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'>0</span> <span class='Function'>×</span> <span class='Number'>1</span><span class='Ligature'></span><span class='Number'>2</span><span class='Ligature'></span><span class='Number'>3</span><span class='Function'>×</span><span class='Modifier'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'>10</span>
⟨ 2 20 ⟩

    <span class='Value'>m</span> <span class='Function'>+</span><span class='Modifier'>˝</span><span class='Modifier2'></span><span class='Function'>×</span><span class='Modifier2'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'></span> <span class='Number'>1</span><span class='Ligature'></span><span class='Number'>2</span><span class='Ligature'></span><span class='Number'>3</span><span class='Function'>×</span><span class='Modifier'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'>10</span>
┌─        
╵  2  20  
  ¯1 ¯10  
   3  30  
         ┘
</pre>
<p>For completeness, here's the whole, boring description of how <code><span class='Function'>𝔾</span></code> is handled. The operand <code><span class='Function'>𝔾</span></code> is called on the arguments <code><span class='Value'>𝕨</span><span class='Function'>𝔾</span><span class='Value'>𝕩</span></code> before doing anything else (if it's not a function, this just returns <code><span class='Value'>𝕘</span></code>). Then it's converted to a list. It's required to have rank 0 or 1, but numbers and enclosed numbers are fine. This list can have one to three elements; three elements is the general case, as the elements give the ranks for monadic <code><span class='Value'>𝕩</span></code>, dyadic <code><span class='Value'>𝕨</span></code>, and dyadic <code><span class='Value'>𝕩</span></code> in order. If there are less than three elements, the list <code><span class='Value'>r</span></code> is expanded backwards-cyclically to <code><span class='Number'>3</span><span class='Modifier2'></span><span class='Function'></span><span class='Modifier2'></span><span class='Function'></span><span class='Value'>r</span></code>, turning <code><span class='Bracket'></span><span class='Value'>a</span><span class='Bracket'></span></code> into <code><span class='Value'>a</span><span class='Ligature'></span><span class='Value'>a</span><span class='Ligature'></span><span class='Value'>a</span></code> and <code><span class='Value'>a</span><span class='Ligature'></span><span class='Value'>b</span></code> into <code><span class='Value'>b</span><span class='Ligature'></span><span class='Value'>a</span><span class='Ligature'></span><span class='Value'>b</span></code>. So <code><span class='Number'>3</span><span class='Modifier2'></span><span class='Function'></span><span class='Modifier2'></span><span class='Function'>⌽⥊</span><span class='Value'>𝕨</span><span class='Function'>𝔾</span><span class='Value'>𝕩</span></code> is the final formula.</p>
<h3 id="leading-axis-agreement"><a class="header" href="#leading-axis-agreement">Leading axis agreement</a></h3>
<p>In the preceding sections we've been somewhat loose with the way two arguments are paired up. The simple answer is <a href="leading.html#leading-axis-agreement">leading axis agreement</a> on the frames.</p>
<p>This is why the rank of <code><span class='Modifier2'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'></span></code> that leads to a frame <code><span class='Bracket'></span><span class='Number'>3</span><span class='Bracket'></span></code> on the left and <code><span class='Bracket'>⟨⟩</span></code> on the right is fine: more generally, either argument can have a longer frame as long as the elements in the shorter one agree with it. So frames of <code><span class='Bracket'></span><span class='Number'>3</span><span class='Separator'>,</span><span class='Number'>2</span><span class='Bracket'></span></code> and <code><span class='Bracket'></span><span class='Number'>3</span><span class='Bracket'></span></code> would also be fine, but <code><span class='Bracket'></span><span class='Number'>2</span><span class='Separator'>,</span><span class='Number'>3</span><span class='Bracket'></span></code> and <code><span class='Bracket'></span><span class='Number'>3</span><span class='Bracket'></span></code> wouldn't: the first axes of these frames need to have the same length.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4omiICjihpUz4oC/MuKAvzUpIOKIvuKOiTEgKOKGlTPigL80KQoK4omiICjihpUy4oC/M+KAvzUpIOKIvuKOiTEgKOKGlTPigL80KQ==">↗️</a><pre>    <span class='Function'></span> <span class='Paren'>(</span><span class='Function'></span><span class='Number'>3</span><span class='Ligature'></span><span class='Number'>2</span><span class='Ligature'></span><span class='Number'>5</span><span class='Paren'>)</span> <span class='Function'></span><span class='Modifier2'></span><span class='Number'>1</span> <span class='Paren'>(</span><span class='Function'></span><span class='Number'>3</span><span class='Ligature'></span><span class='Number'>4</span><span class='Paren'>)</span>
⟨ 3 2 9 ⟩

    <span class='Function'></span> <span class='Paren'>(</span><span class='Function'></span><span class='Number'>2</span><span class='Ligature'></span><span class='Number'>3</span><span class='Ligature'></span><span class='Number'>5</span><span class='Paren'>)</span> <span class='Function'></span><span class='Modifier2'></span><span class='Number'>1</span> <span class='Paren'>(</span><span class='Function'></span><span class='Number'>3</span><span class='Ligature'></span><span class='Number'>4</span><span class='Paren'>)</span>
<span class='Error'>Error: ⎉: Argument frames don't agree (2‿3‿5 ≡ ≢𝕨, 3‿4 ≡ ≢𝕩, common frame of 1 axes)</span>
</pre>
<p>On the other hand, Rank doesn't care about the argument cell shapes—it leaves that up to the function <code><span class='Function'>𝔽</span></code>. If <code><span class='Function'>𝔽</span></code> is an arithmetic function, you'll get <em>two</em> layers of prefix agreement: one outer matching with <code><span class='Modifier2'></span></code>, and an inner one with <code><span class='Function'>𝔽</span></code>.</p>
<p>It's also possible to apply multiple copies of Rank, which in general is powerful enough to match and not-match axes in any combination as long as the axes for each argument stay in order (of course, BQN also provides the tools to <a href="transpose.html#reorder-axes">reorder axes</a>).</p>
<p>One of the relatively more common instance of this pattern is a variation on the <a href="map.html#table">Table</a> modifier, to work with cells instead of elements. Here we'll make a table of all combinations of one row (1-cell) from <code><span class='Value'>𝕨</span></code> and one from <code><span class='Value'>𝕩</span></code>. To do this, we want to first line up each row of <code><span class='Value'>𝕨</span></code> with the whole of <code><span class='Value'>𝕩</span></code>. As in a matrix product, that's <code><span class='Modifier2'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'></span></code>. But then we'd like to pair that row with the rows of <code><span class='Value'>𝕩</span></code> individually, which could be written <code><span class='Modifier2'></span><span class='Number'></span><span class='Ligature'></span><span class='Number'>1</span></code>. But since we know the left argument has been reduced to lists, <code><span class='Modifier2'></span><span class='Number'>1</span></code> also works. We then arrange the two layers of mapping with <code><span class='Modifier2'></span><span class='Number'>1</span></code> on the inside, giving <code><span class='Paren'>(</span><span class='Function'></span><span class='Modifier2'></span><span class='Number'>1</span><span class='Paren'>)</span><span class='Modifier2'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'></span></code>.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KCJhYmMi4omNImRlZiIpIOKIvuKOiTHijokx4oC/4oieID4iUVIi4oC/IlNUIuKAvyJVViIKCuKJoiAoImFiYyLiiY0iZGVmIikg4oi+4o6JMeKOiTHigL/iiJ4gPiJRUiLigL8iU1Qi4oC/IlVWIgoK4omiICjihpUz4oC/NOKAvzUpIOKIvuKOiTHijokx4oC/4oieIOKGlTDigL8x4oC/MuKAvzg=">↗️</a><pre>    <span class='Paren'>(</span><span class='String'>&quot;abc&quot;</span><span class='Function'></span><span class='String'>&quot;def&quot;</span><span class='Paren'>)</span> <span class='Function'></span><span class='Modifier2'></span><span class='Number'>1</span><span class='Modifier2'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'></span> <span class='Function'>&gt;</span><span class='String'>&quot;QR&quot;</span><span class='Ligature'></span><span class='String'>&quot;ST&quot;</span><span class='Ligature'></span><span class='String'>&quot;UV&quot;</span>
┌─       
╎"abcQR  
  abcST  
  abcUV  
         
 ·defQR  
  defST  
  defUV" 
        ┘

    <span class='Function'></span> <span class='Paren'>(</span><span class='String'>&quot;abc&quot;</span><span class='Function'></span><span class='String'>&quot;def&quot;</span><span class='Paren'>)</span> <span class='Function'></span><span class='Modifier2'></span><span class='Number'>1</span><span class='Modifier2'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'></span> <span class='Function'>&gt;</span><span class='String'>&quot;QR&quot;</span><span class='Ligature'></span><span class='String'>&quot;ST&quot;</span><span class='Ligature'></span><span class='String'>&quot;UV&quot;</span>
⟨ 2 3 5 ⟩

    <span class='Function'></span> <span class='Paren'>(</span><span class='Function'></span><span class='Number'>3</span><span class='Ligature'></span><span class='Number'>4</span><span class='Ligature'></span><span class='Number'>5</span><span class='Paren'>)</span> <span class='Function'></span><span class='Modifier2'></span><span class='Number'>1</span><span class='Modifier2'></span><span class='Number'>1</span><span class='Ligature'></span><span class='Number'></span> <span class='Function'></span><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'>8</span>
⟨ 3 4 0 1 2 13 ⟩
</pre>
<p>The flexibility of Rank also means we're able to apply this pattern with ranks other than 1. In particular, <code><span class='Function'>𝔽</span><span class='Modifier2'></span><span class='Number'></span><span class='Ligature'></span><span class='Number'>¯1</span><span class='Modifier2'></span><span class='Number'>¯1</span><span class='Ligature'></span><span class='Number'></span></code> applies <code><span class='Function'>𝔽</span></code> to all combinations of one major cell from either argument—an equivalent to <code><span class='Function'>&gt;𝔽</span><span class='Modifier'></span><span class='Modifier2'></span><span class='Paren'>(</span><span class='Function'>&lt;</span><span class='Modifier'>˘</span><span class='Paren'>)</span></code>. In this case the left rank of <code><span class='Function'>𝔽</span><span class='Modifier2'></span><span class='Number'></span><span class='Ligature'></span><span class='Number'>¯1</span></code> is unknown, so the only way to apply <code><span class='Function'>𝔽</span></code> to the entire cell from <code><span class='Value'>𝕨</span></code> is to use rank ∞.</p>