utils: Add variable-mapping?.

This commit is contained in:
Sergiu Ivanov 2020-02-19 23:25:00 +01:00
parent ae7b9553de
commit 808516081d
1 changed files with 7 additions and 2 deletions

View File

@ -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.