blob: f5fc40a2ac17fa56d10dcc10b3882c20a17e3ca8 (
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
|
*View this file with results and syntax highlighting [here](https://mlochbaum.github.io/BQN/help/⥊deshape reshape.html).*
# Barb (`⥊`)
`⥊ 𝕩`: Deshape
Put all elements of `𝕩` in a rank 1 array, converting to array if necessary.
⥊ 1
⟨ 1 ⟩
⥊ 1‿2 ≍ 3‿4
⟨ 1 2 3 4 ⟩
`𝕨 ⥊ 𝕩`: Reshape
Put all elements of `𝕩` in an array of shape `𝕨`, adding or removing elements if necessary.
A single element in `𝕩` can be a function, which will be replaced with an appropriate length:
- `∘` Exact fit
- `⌊` Round length down, discarding elements
- `⌽` Round length up
- `↑` Round length up, and use element fill to add extra elements.
3‿3 ⥊ 3
┌─
╵ 3 3 3
3 3 3
3 3 3
┘
2‿⌽‿2 ⥊ 1‿2‿3
┌─
╎ 1 2
3 1
┘
2‿↑‿2 ⥊ 1‿2‿3
┌─
╎ 1 2
3 0
┘
|