sydney.lambda
2019-9-29 21:22:22

Is there a function in the standard library that allows you to provide several keys into a hash-of-hashes? So, Instead of something like this: (define (get-thing key1 key2 key3) (hash-ref (hash-ref (hash-ref things key1) key2) key3)) something like this: (define (get-thing key1 key2 key3) (hash-ref! things key1 key2 key3)) I wrote a stripped down version of Clojure’s get-in which does the job: (define (get-in h ks) (cond [(empty? ks) h] [else (let ([k (first ks)]) (let ([h (hash-ref h k)]) (get-in h (rest ks))))])) and the lens package has a great nested-dict lens, but I just wondered if there’s a stdlib equivalent. Thanks :)


soegaard2
2019-9-29 21:24:17

I think the answer is no when it is comes to the standard library. There might be third party libraries that provides such a function — but I don’t know of any.


sydney.lambda
2019-9-29 21:25:05

Thanks, just wanted to be sure. I’ll use the function from the lens package.