diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-10-02 20:37:08 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-10-02 21:01:23 -0400 |
| commit | f6a7c636f8187a8e324901e6671d04c759d5e4c7 (patch) | |
| tree | dacba2c5c453b241c72bf341627791b4f0461bf0 /src | |
| parent | 62fd9972759daeb5fd313b634fb3a27425acbdbe (diff) | |
Simplify vertical padding when formatting
Diffstat (limited to 'src')
| -rw-r--r-- | src/fmt.bqn | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/fmt.bqn b/src/fmt.bqn index def46f58..61bd8639 100644 --- a/src/fmt.bqn +++ b/src/fmt.bqn @@ -1,7 +1,7 @@ # Format an array to a string including newlines { - F0βπ½ # Function to format an atom - FmtAtom β (β <β@βΆβ¨@βΈβ βΆβ¨"@","'"βΈ(βΎβΎβ£)β©,F0β©) + F0βπ½ # Format a number or operation to a string + FmtAtom β β <β@βΆβ¨@βΈβ βΆβ¨"@","'"βΈ(βΎβΎβ£)β©,F0β© # Vertical padding for arrays of rank greater than 2 PadV β { @@ -12,8 +12,10 @@ 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ββ’π©) β₯ π© + # If π© has cells, pad by selection; if it's empty, there are only + # pads but selection would try to get cells (1β above), so overtake. + Pad β {(Β»βΈ<βΈΓ/0βΎ1+π¨) β ' 'Β¨βββΈβΎπ©} + p (0<β ββ’)βΆβ¨+Β΄βΈβ,Padβ© ((ΓΒ΄ls)βΎΒ―1ββ’π©) β₯ π© }β(2 < =) # Horizontal padding: just some spaces on either side @@ -30,7 +32,7 @@ l β Β―1 β β’π© βΎ β¨ βlββΎβ¨"β",(5βΈ<)βΆβ¨β₯"Β·β"βΛ1ββ’,F0β©π¨β© - ((4β0βπ¨-1)β"Β·β΅βββ")βΎβ π© + ((0β4βπ¨-1)β"Β·β΅βββ")βΎβ π© βl-βΈβ"β" β© } |
