Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
17
Task/Align-columns/Uiua/align-columns.uiua
Normal file
17
Task/Align-columns/Uiua/align-columns.uiua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Split the text at $ and then justify each word 3 ways
|
||||
N ← {"Given$a$text$file$of$many$lines,$where$fields$within$a$line$"
|
||||
"are$delineated$by$a$single$'dollar'$character,$write$a$program"
|
||||
"that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$"
|
||||
"column$are$separated$by$at$least$one$space."
|
||||
"Further,$allow$for$each$word$in$a$column$to$be$either$left$"
|
||||
"justified,$right$justified,$or$center$justified$within$its$column."}
|
||||
Ls ← ≡⍚(⊜□≠@$.)N # Get the word arrays
|
||||
P ← +1/↥≡◇⧻/◇⊂Ls # Padding = Max length + 1
|
||||
PadL ← /↥⬚@ ⊟↯P@
|
||||
PadR ← ⍜⇌PadL
|
||||
PadC ← PadL⊂↯:@ ⌊÷2-:P⧻.
|
||||
Format! ← ≡&p≡(□/⊂≡◇^!°□)
|
||||
# Demonstration of use of an array macro, which actually just resolves to
|
||||
# ⊃(Format!PadC|Format!PadR|Format!PadL)Ls
|
||||
Fall‼! ←^ $"⊃(_)"/⊂≡($"Format!_ |"°□)⇌
|
||||
Fall‼!PadL PadR PadC Ls
|
||||
Loading…
Add table
Add a link
Reference in a new issue