[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Modifying nested dictionary/alist type data
From: |
Paul Morris |
Subject: |
Modifying nested dictionary/alist type data |
Date: |
Thu, 14 Apr 2016 19:44:46 -0400 |
Hi, I’m rewriting one of LilyPond's C++ routines in Guile/Scheme in order to
customize it for my own use, and it uses some nested dictionary/map/alist-style
data structures that you can modify using something like this in C++:
mydata[aaa][bbb].ccc = 10;
Ok, maybe use alists, but how to modify the nested values? ...given that you
need an extra “set!” operation to do this reliably, as shown in the
documentation:
(set! address-list
(assoc-set! address-list "bob" "11 Newington Avenue"))
But if you have nested alists like this
(define my-alist ‘((aaa . ((bbb . ((ccc . 10)))))))
and you want to change ccc, then the “set!” trick doesn’t help. (...what would
you “set!”?) So what’s the best approach here for such nested data structures?
Maybe I should just use nested hash maps instead? Sorry if I’m missing
something obvious.
Thanks,
-Paul
- Modifying nested dictionary/alist type data,
Paul Morris <=