summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-02-25 10:40:15 -0500
committerDavid Thompson <dthompson2@worcester.edu>2023-06-08 08:14:41 -0400
commitd038bc439d8b0801671546e73471cb03279d7852 (patch)
treecdc411c6ea2262dd7e021a7f39c8fbe4c5447262
parent3af5bc36fa16057c0a8212d8e4b0582504ec5dd5 (diff)
Allow lookup* to return a default.
-rw-r--r--chickadee/graphics/seagull.scm8
1 files changed, 6 insertions, 2 deletions
diff --git a/chickadee/graphics/seagull.scm b/chickadee/graphics/seagull.scm
index d03de86..abd4429 100644
--- a/chickadee/graphics/seagull.scm
+++ b/chickadee/graphics/seagull.scm
@@ -142,8 +142,12 @@
(make-exception-with-message "seagull: unbound variable")
(make-exception-with-irritants (list name (env-names env)))))))
-(define (lookup* name env)
- (assq-ref env name))
+(define* (lookup* name env #:optional default)
+ (let loop ((env env))
+ (match env
+ (() default)
+ (((k . v) . rest)
+ (if (eq? k name) v (loop rest))))))
(define (lookup-all names env)
(map (lambda (name) (lookup name env)) names))