From 32c7ecd7326f05673d0f3ff751ae4e4bc43f36cb Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 25 Aug 2020 10:22:55 -0400 Subject: Include fmt.bqn from md.bqn instead of duplicating the code --- src/fmt.bqn | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') 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⊣) 𝕩 } -- cgit v1.2.3