diff options
author | David Thompson <dthompson2@worcester.edu> | 2023-02-25 10:40:15 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2023-06-08 08:14:41 -0400 |
commit | d038bc439d8b0801671546e73471cb03279d7852 (patch) | |
tree | cdc411c6ea2262dd7e021a7f39c8fbe4c5447262 | |
parent | 3af5bc36fa16057c0a8212d8e4b0582504ec5dd5 (diff) |
Allow lookup* to return a default.
-rw-r--r-- | chickadee/graphics/seagull.scm | 8 |
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)) |