Q: what is the idiomatic way to map a function across a property list?
The various mapping functions (mapcar
and family) map a function over a sequence such as a list. How does one use these functions when dealing with a property list, i.e., when trying to map across each of the properties contained in the list (which would be every other element starting from the first one)? It seems to me that the mapping function would need to access the list in pairs of elements rather than as individual elements.
As a toy example, how would one take a property list and collect all of the property values? If it were an association list instead it would be pretty simple:
(mapcar #'cadr '((:prop1 a) (:prop2 b) (:prop3 c))) ;=> (a b c)
I'm sure this could be done with a loop, but it seems a little laborious and I'm wondering if there's a more idiomatic way to do it.
mapcar
alist example does) or you want to map over the pairs of property symbol and property value. The latter is more general (more generally useful), I would guess.