aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-04-11 22:18:25 +0200
committerThomas White <taw@physics.org>2023-04-11 22:18:25 +0200
commit8b64630d79c3d485dea7161c3e917e06f75ecc4a (patch)
tree85e4e9d0717bb736dec51698ccc6e61726c8e2c0
parent997502be5b815f4c199395e92e75944411e0d005 (diff)
Add 'lookup' utility
-rw-r--r--guile/starlet/utils.scm13
1 files changed, 12 insertions, 1 deletions
diff --git a/guile/starlet/utils.scm b/guile/starlet/utils.scm
index 5542668..e38e6b7 100644
--- a/guile/starlet/utils.scm
+++ b/guile/starlet/utils.scm
@@ -39,7 +39,8 @@
percent->dmxval8
percent->dmxval16
comment
- hash-table-empty?))
+ hash-table-empty?
+ lookup))
(define (print-hash-table ht)
@@ -162,3 +163,13 @@
(return #f))
ht)
#t))
+
+
+(define (lookup key dictionary)
+ (cond
+ ((nil? dictionary)
+ #f)
+ ((eq? key (caar dictionary))
+ (cadr (car dictionary)))
+ (else
+ (lookup key (cdr dictionary)))))