From 2f842e30775a1ad86cce7e30438cfe1dcc067fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 31 Jan 2022 20:38:44 +0100 Subject: Add tree-node. --- module/calp/html/view/calendar/shared.scm | 4 ++-- module/hnh/util/tree.scm | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/module/calp/html/view/calendar/shared.scm b/module/calp/html/view/calendar/shared.scm index de09e00a..11f1a70c 100644 --- a/module/calp/html/view/calendar/shared.scm +++ b/module/calp/html/view/calendar/shared.scm @@ -43,8 +43,8 @@ (unless (null? tree) (let ((w (/ (- 1 x) (+ 1 (length-of-longst-branch (left-subtree tree)))))) - (set! (width (car tree)) w - (x-pos (car tree)) x) + (set! (width (tree-node tree)) w + (x-pos (tree-node tree)) x) (inner (+ x w) (left-subtree tree)) (inner x (right-subtree tree)))))) diff --git a/module/hnh/util/tree.scm b/module/hnh/util/tree.scm index 6c4f765d..95328b5f 100644 --- a/module/hnh/util/tree.scm +++ b/module/hnh/util/tree.scm @@ -3,6 +3,7 @@ #:use-module (hnh util) #:export (make-tree left-subtree right-subtree + tree-node length-of-longst-branch tree-map)) @@ -18,6 +19,9 @@ (make-tree pred? head) (make-tree pred? tail))))) +(define (tree-node tree) + (car tree)) + (define (left-subtree tree) (list-ref tree 1)) -- cgit v1.2.3