I have defined dictionary as this judgment in BNF grammar:
d ::= () (any boolean) (list cons d d)
Meaning, dictionaries are empty, or (any boolean) or a list of such pairs.
If I want to create a mapping, say "a true", how do I do it?
If I do
(define-values (d) (values '(a true)))
it just creates a new d, doesn't map to previous judgment d defined.
IIUC you want your dictionary to be just an association list:
Depending on how are you going to implement the add operation you could either
set!
a new mapping:Or just create a new list (preferred):
Either way, the dictionary
d
will have the new mapping in the expected format: