unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Modifying nested dictionary/alist type data
@ 2016-04-14 23:44 Paul Morris
  2016-04-15 14:00 ` Wette, Matthew R (3441)
  2016-04-15 17:20 ` Andreas Rottmann
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Morris @ 2016-04-14 23:44 UTC (permalink / raw)
  To: guile-user

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




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-16 14:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-14 23:44 Modifying nested dictionary/alist type data Paul Morris
2016-04-15 14:00 ` Wette, Matthew R (3441)
2016-04-15 17:20 ` Andreas Rottmann
2016-04-16 14:37   ` Paul Morris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).