Just because I needed a simple way to display various numbers (non-rationals, large integers, floats, etc.) in a table, I ended up rewriting text-table
almost entirely, except for frame styles (which were also enhanced relatively recently).
What's new:
- Rows can be aligned 'top, 'center, 'bottom for when cells are multiline.
-
#:->string
,#:align
and#:row-align
arguments use the rather flexiblepattern-list->list
:-
(pattern-list->list '(a B C ... ... d) 10)
β(a B C B C B C B C d)
-
-
~r*
can be used with->string
to easily format columns of numbers (possibly including text) - The source code is way more readable, factored and tested, which should help contributing.
(The online docs may take some time to reflect the changes. Download/update the package to get the latest docs.)
Feedback most welcome. Let me know in particular if I've broken your code in any way. I will allow for backward incompatible changes to these new features until the end of March, waiting for feedback.
Some examples:
(let ()
(define l (build-list 10 (Ξ» (i) (expt (random) -4))))
(print-table
#:row-sep? #f
#:align 'right
#:->string (list (~r* #:precision '(= 2))
(~r* #:precision '(= 2) #:notation 'exponential))
(transpose (list (list* 'Speed "" l) (list* 'Height "" (reverse l))))))
ββββββββββ¬βββββββββ
β Speedβ Heightβ
β β β
β 20.36β2.65e+00β
β44887.08β3.58e+03β
β 2.99β1.14e+00β
β 4.82β3.30e+01β
β 4181.24β4.42e+01β
β 44.19β4.18e+03β
β 33.03β4.82e+00β
β 1.14β2.99e+00β
β 3579.13β4.49e+04β
β 2.65β2.04e+01β
ββββββββββ΄βββββββββ
(print-simple-table
#:border-style 'empty
#:align '(right left ... ...)
(list (make-list 10 '*)
(make-list 10 '**)
(make-list 10 '***)
(make-list 10 '****)
(make-list 10 '*****)
(make-list 10 "|")))
** ** ** ** **
**** **** **** **** ****
****** ****** ****** ****** ******
******** ******** ******** ******** ********
**************************************************
|| || || || ||
Make sure to also check out uni-table which has many options and can use ansi colours.