[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to iterate over properties in a plist?
From: |
Pascal J. Bourguignon |
Subject: |
Re: How to iterate over properties in a plist? |
Date: |
Sat, 01 Aug 2015 01:34:55 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Marcin Borkowski <mbork@mbork.pl> writes:
> Hi all,
>
> I need to iterate over all properties in a plist. Obviously, mapcar (or
> mapc, since I need side effects only) is of no use for me. I can easily
> write a plist-mapc function:
>
> (defun plist-mapc (function plist)
> "Iterate FUNCTION (a two-argument function) over PLIST. Error
> checking is for weenies."
> (when plist
> (funcall function (car plist) (cadr plist))
> (plist-mapc function (cddr plist))))
>
> but maybe it's there already?
There's:
(loop for (k v) on p-list by (function cddr)
do (something-with :key k :value v))
But you might still want to abstrat it away in a map-plist function.
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk
- Re: How to iterate over properties in a plist?,
Pascal J. Bourguignon <=