From 808516081df68e53290b898075ae06bd05bb04f7 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Wed, 19 Feb 2020 23:25:00 +0100 Subject: [PATCH] utils: Add variable-mapping?. --- utils.rkt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils.rkt b/utils.rkt index 800f235..5d8a99d 100644 --- a/utils.rkt +++ b/utils.rkt @@ -8,8 +8,7 @@ (for-syntax racket/list)) (provide auto-hash-ref/explicit auto-hash-ref/:) -(provide (contract-out [eval-with (-> hash? any/c any)] - [eval-with1 (-> hash? any/c any/c)] +(provide (contract-out [eval-with (-> variable-mapping? any/c any)] [extract-symbols (-> any/c list?)])) ;;; =================== @@ -20,6 +19,12 @@ ;;; usage of hash tables mapping symbols to values. The goal is ;;; essentially to avoid having to write explicit hash-ref calls. +(define (variable-mapping? dict) + (and (hash? dict) + (if (not (hash-empty? dict)) + (symbol? (car (hash-keys dict))) + #t))) + ;;; Given a (HashTable Symbol a) and a sequence of symbols, binds ;;; these symbols to the values they are associated to in the hash ;;; table, then puts the body in the context of these bindings.