[racket] Nested hash table update

From: Ramakrishnan Muthukrishnan (vu3rdd at gmail.com)
Date: Sun Jul 10 12:18:50 EDT 2011

On Sun, Jul 10, 2011 at 9:28 PM, Ramakrishnan Muthukrishnan
<vu3rdd at gmail.com> wrote:
> Is there a way to use hash-set on a nested hash table and set the
> value of a deeply nested key and return the entire updated hash table
> ?

Ok, I wrote this function which serves my purpose:

(define (hash-set-in ht ks v)
  (cond [(not (list? ks)) (error "ks not a list")]
        [(empty? (cdr ks)) (hash-set ht (car ks) v)]
         (hash-set ht
                   (car ks)
                   (hash-set-in (hash-ref ht (car ks))
                                (cdr ks)


Posted on the users mailing list.