28 lines
842 B
Plaintext
28 lines
842 B
Plaintext
@(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)
|