aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-04-29 23:13:43 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-04-29 23:13:43 -0400
commit62e14d343cc6e1122a0f2c6970b89e85a2aa8af2 (patch)
treedb5265130de61e5299ecad87c15c5d2c0fb21367 /src
parent6552ee510970d18b48be31c5a08301fbf826fe0b (diff)
Allow formatter 𝕨 for maximum output size, truncating with …
Diffstat (limited to 'src')
-rw-r--r--src/f.bqn10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/f.bqn b/src/f.bqn
index ebfb5c5e..859c5fff 100644
--- a/src/f.bqn
+++ b/src/f.bqn
@@ -95,6 +95,14 @@
# Format any value to character matrix
Fmt ← Type (3≤⊣)◶⟨FmtDat⊢,FmtOp⟩ ⊢
+ Trunc ← {
+ m ← "•Fmt: 𝕨 must be a list of up to two numbers (width, height)"
+ m ! (1≥=)◶⟨0,2≥≠⟩ 𝕨
+ sh ← ⌽𝕨»∞‿∞
+ c ← sh<s←≢ f ← 𝕩
+ sh {l←c-˜𝕨⌊s ⋄ ls←⋈⌜´l∾⟜(⥊⟜1)¨c ⋄ ∾ ls ⥊¨ (l↑f)⌾⊑ '…'¨ ls}⍟(∨´c) f
+ }
+ FmtW ← Fmt⊘(Trunc⟜Fmt)
# Represent as string
RR ← {Repr𝕩}
@@ -109,5 +117,5 @@
Repr ← Type (3≤⊣)◶⟨ReprDat⊢,ReprOp⟩ ⊢
# Convert Fmt from matrix to string
- ⟨¯1↓·⥊ ∾⟜(@+10)˘∘Fmt, Repr⟩
+ ⟨¯1↓·⥊ ∾⟜(@+10)˘∘FmtW, Repr⟩
}