diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-08-25 10:22:55 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-08-25 10:22:55 -0400 |
| commit | 32c7ecd7326f05673d0f3ff751ae4e4bc43f36cb (patch) | |
| tree | 4894c62319602a56ee6260b62b118e28cdfc5e5d /src | |
| parent | 0d287cb8d4c3253618136cbd5631bc6f534c4c55 (diff) | |
Include fmt.bqn from md.bqn instead of duplicating the code
Diffstat (limited to 'src')
| -rw-r--r-- | src/fmt.bqn | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/fmt.bqn b/src/fmt.bqn index 7869b4a2..d5b3d355 100644 --- a/src/fmt.bqn +++ b/src/fmt.bqn @@ -1,14 +1,21 @@ -lf←' -' +# Format an array to a character matrix { - F0←𝔽 + F0←𝔽 # Function to format a scalar + lf←' +' + # Vertical padding for arrays of rank greater than 2 PadV ← { + # Leading shape ls ← ¯1↓≢𝕩 + # Empty lines after each row: 1 if it's at the end of a 2-cell, plus + # 1 if it's at the end of a 2-cell and a 3-cell, and so on p ← ⥊ +⎉¯1‿∞´ ×⌜˜`⌾⌽ (-1⌈ls)↑¨1 + # But none at the very end p ↩ 0⌾(¯1⊸⊑) p Pad ← {i←/1+𝕨 ⋄ (¯1¨⌾((¬∊i)⊸/)i) ⊏ 𝕩∾(¯1⊑≢𝕩)⥊" "} p (⊑0∊ls)◶⟨Pad,+´⊸↑⟩ ((×´ls)∾¯1⊑≢𝕩) ⥊ 𝕩 }⍟(2 < =) + # Horizontal padding: just some spaces on either side PadH ← { (𝕨/" ") (∾⎉1∾⎉1⊣) 𝕩 } |
