[英]How to define a hashtable of hashtable in Racket?
I want to define a hash table to represent such a data structure: 我想定义一个哈希表来表示这样的数据结构:
(("A" , ("B" ,16)) , ("B" , ("C" , 20))) ((“A”,(“B”,16)),(“B”,(“C”,20)))
and I need to access to the both pairs: ("B" ,16),("C" ,20) and numbers 16,20. 我需要访问两对:(“B”,16),(“C”,20)和数字16,20。
Can I have a hashtable of hashtable in Racket? 我可以在Racket中使用散列表哈希表吗? how should I define it and access to to elements?
我该如何定义它并访问元素?
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")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.