Allow generating table as list of strings.
This commit is contained in:
parent
3739a8d1b0
commit
c69b545aa1
1 changed files with 10 additions and 5 deletions
|
@ -29,6 +29,7 @@
|
|||
table
|
||||
(
|
||||
*table-border-style*
|
||||
table->list
|
||||
table->string
|
||||
table-tests!
|
||||
)
|
||||
|
@ -270,8 +271,8 @@
|
|||
(if cb (sref 2) "")
|
||||
(if tb (sref 3) "")))
|
||||
|
||||
;; Converts given table to a string suitable for printing.
|
||||
(define (table->string tbl . args)
|
||||
;; Converts given table to a list of strings suitable for printing.
|
||||
(define (table->list tbl . args)
|
||||
(let ((table (table-prepare tbl)))
|
||||
(if (or (null? tbl)
|
||||
(null? (car tbl)))
|
||||
|
@ -315,9 +316,7 @@
|
|||
3)
|
||||
res)
|
||||
res)))
|
||||
(string-intersperse
|
||||
(flatten (reverse res0))
|
||||
"\n"))
|
||||
(flatten (reverse res0)))
|
||||
(let* ((res0
|
||||
(if (or (and row-border
|
||||
(> idx 0))
|
||||
|
@ -341,6 +340,12 @@
|
|||
res1
|
||||
(add1 idx)))))))))
|
||||
|
||||
;; Converts into single string
|
||||
(define (table->string . args)
|
||||
(string-intersperse
|
||||
(apply table->list args)
|
||||
"\n"))
|
||||
|
||||
;; Performs module self-tests
|
||||
(define (table-tests!)
|
||||
(run-tests
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue