Align columns: Difference between revisions

m
(→‎{{header|J}}: define reusable verb)
Line 759:
NB.* alignCols v Format delimited text in justified columns
NB. result: literal table
NB. y is: literal list to format, fields delimited by $
NB. x is: optionally specify justification. Default is LEFT
alignCols=: verb define
Line 766:
currboxchars=. 9!:6 '' NB. store current settings so can restore later
currboxalign=. 9!:16 ''
(9!:7) 11$' ' NB. set list of box characters to spacespaces
9!:17 ,~ x NB. set box alignment
res=. _2{:\ ": <;._2 @:(,&'$') &> <;._2 y
9!:17 currboxalign NB. restore settings
(9!:7) currboxchars
res NB. return result
)
892

edits