aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-12-08 21:52:17 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2023-12-09 00:54:20 +0100
commit5ee81889f4992e29fcc475e6f4687be393ba4c18 (patch)
treed4e2c7dbd5a9f27a3206bc8c877446a600d727e1
parentComplete rewrite of the lens system. (diff)
downloadcalp-5ee81889f4992e29fcc475e6f4687be393ba4c18.tar.gz
calp-5ee81889f4992e29fcc475e6f4687be393ba4c18.tar.xz
Better table printer.
-rw-r--r--module/hnh/util/table.scm20
1 files changed, 13 insertions, 7 deletions
diff --git a/module/hnh/util/table.scm b/module/hnh/util/table.scm
index b318cf77..67125c8d 100644
--- a/module/hnh/util/table.scm
+++ b/module/hnh/util/table.scm
@@ -16,6 +16,7 @@
(tree-remove . table-remove)
(tree->list . table->list)
(tree? . table?)
+ (serialize-tree . serialize-table)
(alist->tree . alist->table)))
(define (symbol<? . args)
@@ -24,15 +25,20 @@
(define-syntax-rule (symbol< args ...)
(string< (symbol->string args) ...))
+(define (serialize-tree t)
+ `(-> (table)
+ ,@(fold (lambda (p done)
+ (cons `(table-put
+ (quote ,(car p))
+ (quote ,(cdr p)))
+ done))
+ '()
+ (tree->list t))))
+
(define-type (tree-node
printer: (lambda (t p)
- (write
- `(-> (table)
- ,@(fold (lambda (p done)
- (cons `(table-put ,(car p) ,(cdr p))
- done))
- '()
- (tree->list t)))
+ ((@ (ice-9 pretty-print) pretty-print)
+ (serialize-tree t)
p)))
(key type: symbol?)
value