From 8b64630d79c3d485dea7161c3e917e06f75ecc4a Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 11 Apr 2023 22:18:25 +0200 Subject: Add 'lookup' utility --- guile/starlet/utils.scm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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))))) -- cgit v1.2.3