utils: Add sgfy.

This commit is contained in:
Sergiu Ivanov 2020-02-22 10:40:40 +01:00
parent 8dfa11b17c
commit 3a3c0e2d4d
2 changed files with 7 additions and 1 deletions

View File

@ -39,5 +39,8 @@
(check-equal? (any->string '(a 1 (x y))) "(a 1 (x y))") (check-equal? (any->string '(a 1 (x y))) "(a 1 (x y))")
(check-equal? (any->string "hello") "hello") (check-equal? (any->string "hello") "hello")
(let ([mp (variable-mapping-stringify #hash((a . (and a b)) (b . (not b))))]) (let ([mp (variable-mapping-stringify #hash((a . (and a b)) (b . (not b))))])
(check-equal? (hash-ref mp 'a) "(and a b)")
(check-equal? (hash-ref mp 'b) "(not b)"))
(let ([mp (sgfy #hash((a . (and a b)) (b . (not b))))])
(check-equal? (hash-ref mp 'a) "(and a b)") (check-equal? (hash-ref mp 'a) "(and a b)")
(check-equal? (hash-ref mp 'b) "(not b)"))) (check-equal? (hash-ref mp 'b) "(not b)")))

View File

@ -17,7 +17,7 @@
(contract-out [variable-mapping? contract?] (contract-out [variable-mapping? contract?]
[string-variable-mapping? contract?]) [string-variable-mapping? contract?])
;; Syntax ;; Syntax
auto-hash-ref/explicit auto-hash-ref/:) auto-hash-ref/explicit auto-hash-ref/: sgfy)
;;; =================== ;;; ===================
;;; HashTable Injection ;;; HashTable Injection
@ -159,3 +159,6 @@
(define (variable-mapping-stringify ht) (define (variable-mapping-stringify ht)
(make-hash (hash-map ht (λ (key val) (make-hash (hash-map ht (λ (key val)
(cons key (any->string val)))))) (cons key (any->string val))))))
;;; A shortcut for variable-mapping-stingify.
(define-syntax-rule (sgfy ht) (variable-mapping-stringify ht))