Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Align-columns/TXR/align-columns.txr
Normal file
27
Task/Align-columns/TXR/align-columns.txr
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
@(collect)
|
||||
@ (coll)@{item /[^$]+/}@(end)
|
||||
@(end)
|
||||
@; nc = number of columns
|
||||
@; pi = padded items (data with row lengths equalized with empty strings)
|
||||
@; cw = vector of max column widths
|
||||
@; ce = center padding
|
||||
@(bind nc @[apply max [mapcar length item]])
|
||||
@(bind pi @(mapcar (op append @1 (repeat '("") (- nc (length @1)))) item))
|
||||
@(bind cw @(vector-list
|
||||
(mapcar (op apply max [mapcar length @1])
|
||||
;; matrix transpose trick cols become rows:
|
||||
[apply mapcar [cons list pi]])))
|
||||
@(bind ns "")
|
||||
@(output)
|
||||
@ (repeat)
|
||||
@ (rep :counter i)@{pi @[cw i]} @(end)
|
||||
@ (end)
|
||||
@ (repeat)
|
||||
@ (rep :counter i)@{pi @(- [cw i])} @(end)
|
||||
@ (end)
|
||||
@ (repeat)
|
||||
@ (rep :counter i)@\
|
||||
@{ns @(trunc (- [cw i] (length pi)) 2)}@\
|
||||
@{pi @(- [cw i] (trunc (- [cw i] (length pi)) 2))} @(end)
|
||||
@ (end)
|
||||
@(end)
|
||||
Loading…
Add table
Add a link
Reference in a new issue