help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Navigating Lisp data structures


From: Matt
Subject: Re: Navigating Lisp data structures
Date: Tue, 06 Dec 2022 10:36:29 -0500
User-agent: Zoho Mail

 ---- On Sun, 04 Dec 2022 19:46:20 -0500  Joost Kremers  wrote --- 

 > Note that there's also `alist-get`, which should at least help in reducing 
 > the
 > number of cars and cdrs.
 > 
 > You may also want to check out `let-alist`, which actually gives a nice way 
 > to
 > access the elements inside a nested alist.
 
Yes, I had over looked `alist-get` and was unaware of `let-alist`.  Thank you.

For posterity, should anyone have similar questions, here's a translation of my 
nested Python dict into an alist, along with how to access it using `alist-get` 
and `let-alist`:

(setq project-alist
       '((my_c_project .
                       ((shells .
                                ((build .
                                        ((root . "/path/to/build/directory/")
                                         (setup . ("export MYBUILDVAR1=1"
                                                   "export MYBUILDVAR2=0"))))
                                 (run .
                                      ((root . "/path/to/run/directory/")
                                       (setup . ("export MYRUNVAR=1"))))))
                        (commands . ("./build_my_project.sh"
                                     "./run_my_build"))
                        (files . ("/path/to/entrypoint.c"
                                  "/path/to/other/file/I/care/about.c"))
                        (window-split . :quad)))
         (my-python-project .
                            ((shells .
                                     ((my-python-project .
                                                         ((root . 
"/path/to/my/python/project")
                                                          (setup . ("source 
venv/bin/activate"))))))
                             (commands . ("python3 -m my_python_project"
                                          "python3 -m unittest discover tests/ 
--failfast --quiet"))
                             (files . 
("/path/to/my_python_project/entry_point.py"))
                             (window-split . :half)))))

(alist-get 'my_c_project project-alist)

(let-alist project-alist
  .my-python-project.shells.my-python-project.root)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]