I'm using property lists in Common Lisp to represent a binary tree with some additional information. I'd like to be able to dig arbitrarily deep into the tree with a single function, and also modify it accordingly.
In Clojure (which is the other Lisp I use), there exist functions called get-in and assoc-in which can do exactly this, but I haven't found anything similar in Common Lisp. Do they actually exist, or am I going to have to write them?
I have not yet seen the use of nested plists for such a data structure; it may be somewhat unusual. I'd rather expect a structure (defined with
defstruct) or class (defined withdefclass) representing nodes. An alternative for the case of (not too sparse) binary trees is the implementation as an array, where the root node is at index 0 and each node's children at (2 · i + 1) and (2 · i + 2).If you insist on using plists, you will have to nest
getfs and write asetfexpander for nestedgetfs.