aboutsummaryrefslogtreecommitdiff
path: root/docs/help/prefixes_take.html
blob: 61d277408536a9dff30d65ec22e7eecc64e0229d (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
<head>
  <link href="../favicon.ico" rel="shortcut icon" type="image/x-icon"/>
  <link href="../style.css" rel="stylesheet"/>
  <title>BQN: Up Arrow (`↑`)</title>
</head>
<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">help</a></div>
<h1 id="up-arrow-"><a class="header" href="#up-arrow-">Up Arrow (<code><span class='Function'></span></code>)</a></h1>
<h2 id="--prefixes"><a class="header" href="#--prefixes"><code><span class='Function'></span> <span class='Value'>𝕩</span></code>: Prefixes</a></h2>
<p>Prefixes of array <code><span class='Value'>𝕩</span></code> along its first axis.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=ICAg4oaRIDHigL8y4oC/M+KAvzQKCiAgIGEg4oaQIDPigL8zIOKliiDihpU5CgogICDihpEgYQ==">↗️</a><pre>       <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='Ligature'></span><span class='Number'>4</span>
⟨ ⟨⟩ ⟨ 1 ⟩ ⟨ 1 2 ⟩ ⟨ 1 2 3 ⟩ ⟨ 1 2 3 4 ⟩ ⟩

       <span class='Value'>a</span> <span class='Gets'></span> <span class='Number'>3</span><span class='Ligature'></span><span class='Number'>3</span> <span class='Function'></span> <span class='Function'></span><span class='Number'>9</span>

       <span class='Function'></span> <span class='Value'>a</span>
┌─                                    
· ↕0‿3 ┌─        ┌─        ┌─         
       ╵ 0 1 2   ╵ 0 1 2   ╵ 0 1 2    
               ┘   3 4 5     3 4 5    
                         ┘   6 7 8    
                                   ┘  
                                     ┘
</pre>
<h2 id="---take"><a class="header" href="#---take"><code><span class='Value'>𝕨</span> <span class='Function'></span> <span class='Value'>𝕩</span></code>: Take</a></h2>
<p>For each integer in <code><span class='Value'>𝕨</span></code>, take that many elements from each dimension of <code><span class='Value'>𝕩</span></code>.</p>
<p>Negative numbers take from the end.</p>
<p>If any of the elements in <code><span class='Value'>𝕨</span></code> are greater than the length of their respective dimension, the dimension is extended with a fill value.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=ICAzIOKGkSAx4oC/M+KAvzXigL82NwoKICBhIOKGkCA04oC/NCDipYog4oaVMTYKCiAgM+KAvzMg4oaRIGEKCiAgNeKAvzUg4oaRIGEKCiAgM+KAv8KvMyDihpEgYQ==">↗️</a><pre>      <span class='Number'>3</span> <span class='Function'></span> <span class='Number'>1</span><span class='Ligature'></span><span class='Number'>3</span><span class='Ligature'></span><span class='Number'>5</span><span class='Ligature'></span><span class='Number'>67</span>
⟨ 1 3 5 ⟩

      <span class='Value'>a</span> <span class='Gets'></span> <span class='Number'>4</span><span class='Ligature'></span><span class='Number'>4</span> <span class='Function'></span> <span class='Function'></span><span class='Number'>16</span>
<span class='Error'>Error: Redefinition</span>

      <span class='Number'>3</span><span class='Ligature'></span><span class='Number'>3</span> <span class='Function'></span> <span class='Value'>a</span>
┌─       
╵ 0 1 2  
  3 4 5  
  6 7 8  
        ┘

      <span class='Number'>5</span><span class='Ligature'></span><span class='Number'>5</span> <span class='Function'></span> <span class='Value'>a</span>
┌─           
╵ 0 1 2 0 0  
  3 4 5 0 0  
  6 7 8 0 0  
  0 0 0 0 0  
  0 0 0 0 0  
            ┘

      <span class='Number'>3</span><span class='Ligature'></span><span class='Number'>¯3</span> <span class='Function'></span> <span class='Value'>a</span>
┌─       
╵ 0 1 2  
  3 4 5  
  6 7 8  
        ┘
</pre>