aboutsummaryrefslogtreecommitdiff
path: root/module/util/tree.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-04-30 01:10:00 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2019-04-30 01:10:00 +0200
commit0288287f06e3afb4f40459da412206dceaf8067e (patch)
treee664075cfdff5695c6c2d77a88ce25033c59e35b /module/util/tree.scm
parentFix makefile so all also builds guile code. (diff)
downloadcalp-0288287f06e3afb4f40459da412206dceaf8067e.tar.gz
calp-0288287f06e3afb4f40459da412206dceaf8067e.tar.xz
Replace 'when' and 'unless'.
Diffstat (limited to '')
-rw-r--r--module/util/tree.scm20
1 files changed, 10 insertions, 10 deletions
diff --git a/module/util/tree.scm b/module/util/tree.scm
index 8d3e7805..474dc272 100644
--- a/module/util/tree.scm
+++ b/module/util/tree.scm
@@ -11,12 +11,12 @@
;; Has thee form @var{(node left-subtree right-subtree)}. A leaf has
;; both it's children equal to @var{null}.
(define (make-tree pred? lst)
- (if (null? lst) '()
- (let* ((head tail (partition (lambda (el) (pred? (car lst) el))
- (cdr lst))))
- (list (car lst)
- (make-tree pred? head)
- (make-tree pred? tail)))))
+ (unless (null? lst)
+ (let* ((head tail (partition (lambda (el) (pred? (car lst) el))
+ (cdr lst))))
+ (list (car lst)
+ (make-tree pred? head)
+ (make-tree pred? tail)))))
(define (left-subtree tree)
(list-ref tree 1))
@@ -34,7 +34,7 @@
(length-of-longst-branch (right-subtree tree)))))
(define (tree-map proc tree)
- (if (null? tree) '()
- (list (proc (car tree))
- (tree-map proc (left-subtree tree))
- (tree-map proc (right-subtree tree)))))
+ (unless (null? tree)
+ (list (proc (car tree))
+ (tree-map proc (left-subtree tree))
+ (tree-map proc (right-subtree tree)))))