Reputation: 485
I want to define a hash table to represent such a data structure:
(("A" , ("B" ,16)) , ("B" , ("C" , 20)))
and I need to access to the both pairs: ("B" ,16),("C" ,20) and numbers 16,20.
Can I have a hashtable of hashtable in Racket? how should I define it and access to to elements?
Upvotes: 0
Views: 180
Reputation: 485
I found the answer. Yes, it is possible. One can simply do it like:
(define (fun1)
(let ([ht (make-hash (list (cons "A" (make-hash '(("B" "16")("C" "20"))))))])
ht))
(define v (hash-ref (fun1) "A" ))
(hash-ref v "B")
Upvotes: 2