I'm looking for a way to modify a property value in a property list by multiplying it with a given factor similar to using incf for adding to a value.
With incf I could say:
(let ((seq '(:x 10 :y 3)))
(incf (getf seq :y) 3)
seq)
-> (:x 10 :y 5)
Using a macro I could obtain the result in the following way, but this uses getf twice:
(defmacro multf (place val)
`(setf ,place (* ,place ,val)))
(let ((seq '(:x 10 :y 3)))
(multf (getf seq :y) 2)
seq)
-> (:x 10 :y 6)
How would I do this so that I could obtain the same result using getf only once?
Maybe there are packages with this functionality, but I couldn't find it in the net. Any help is appreciated! This is no homework, I'm just trying to optimize my code and I'm curious to better understand the language. I read about setf-expanders and compiler-macros, but I don't know whether they apply here and how to make use of them.