I have a property list:
(setf *star* '(:points 5))
I'd like to modify this plist. Sometimes the better choice is to do mutation, and sometimes the better choice is to use an immutable update.
How to modify the plist using mutation?
(mutate *star* :points 6)
*star* ; '(:points 6)
And how to modify the plist using an immutable update?
(update *star* :points 6) ; '(:points 6)
*star* ; '(:points 5)
What you are looking for are getf and maybe get-properties.
To modify the plist non-destructively, use list*:
(setq *star* (list* :points 6 *star*))
If your plist is associated with a symbol, you should use get and remprop.
NB: it is a much better idea to use association lists (see assoc and acons) because they are more flexible (e.g., it is easier to switch from associating multiple objects with a key using alists).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With