utils: Add variable-mapping?.

This commit is contained in:
Sergiu Ivanov 2020-02-19 23:25:00 +01:00
parent ae7b9553de
commit 808516081d

View file

@ -8,8 +8,7 @@
(for-syntax racket/list)) (for-syntax racket/list))
(provide auto-hash-ref/explicit auto-hash-ref/:) (provide auto-hash-ref/explicit auto-hash-ref/:)
(provide (contract-out [eval-with (-> hash? any/c any)] (provide (contract-out [eval-with (-> variable-mapping? any/c any)]
[eval-with1 (-> hash? any/c any/c)]
[extract-symbols (-> any/c list?)])) [extract-symbols (-> any/c list?)]))
;;; =================== ;;; ===================
@ -20,6 +19,12 @@
;;; usage of hash tables mapping symbols to values. The goal is ;;; usage of hash tables mapping symbols to values. The goal is
;;; essentially to avoid having to write explicit hash-ref calls. ;;; 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 ;;; Given a (HashTable Symbol a) and a sequence of symbols, binds
;;; these symbols to the values they are associated to in the hash ;;; these symbols to the values they are associated to in the hash
;;; table, then puts the body in the context of these bindings. ;;; table, then puts the body in the context of these bindings.