diff options
Diffstat (limited to 'module/hnh/util')
-rw-r--r-- | module/hnh/util/table.scm | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/module/hnh/util/table.scm b/module/hnh/util/table.scm index 67125c8d..94d3c110 100644 --- a/module/hnh/util/table.scm +++ b/module/hnh/util/table.scm @@ -16,6 +16,8 @@ (tree-remove . table-remove) (tree->list . table->list) (tree? . table?) + (tree-empty? . table-empty?) + (tree-equal? . table-equal?) (serialize-tree . serialize-table) (alist->tree . alist->table))) @@ -55,6 +57,14 @@ (or (tree-node? x) (tree-terminal? x))) +(define (tree-empty? x) + (tree-terminal? x)) + +(define (tree-equal? a b) + (or (and (tree-terminal? a) (tree-terminal? b)) + (tree-equal? (left a) (left b)) + (tree-equal? (right a) (right b)))) + ;;; A lens ;;; This function (tree-focus) ;;; returns a function (f), @@ -70,11 +80,11 @@ (cond ((tree-terminal? tree) ;; new node (tree-node key: k value: (op 'not-a-value))) ((eq? k (key tree)) ;; this node - (value tree (op (value truee)))) + (value tree (op (value tree)))) (else (if (symbol<? k (key tree)) (lens-compose left* (tree-focus (left tree) k)) - (lens-compose right* (tree-focus (right tree k)))))))) + (lens-compose right* (tree-focus (right tree) k))))))) (define (tree-put tree k v) (cond ((tree-terminal? tree) (tree-node key: k value: v)) |