[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to delete all nil properties from a plist?
From: |
Marcin Borkowski |
Subject: |
How to delete all nil properties from a plist? |
Date: |
Sun, 02 Aug 2015 00:03:50 +0200 |
Hi all,
so I'm still using plists, though I'm less and less sure that they are
actually better than alists for my use-case. Now I need to delete all
properties whose value is nil. I'm using this function:
--8<---------------cut here---------------start------------->8---
(defun plist-clear (plist)
"Return PLIST with all nil properties deleted."
(cond
((< (length plist) 2) nil)
((null (cadr plist)) (cddr plist))
(t (cons (car plist) (cons (cadr plist) (plist-clear (cddr plist)))))))
--8<---------------cut here---------------end--------------->8---
Question 1: is there a better way to write it? (Especially the last
line.)
Question 2: how would I do the analogous thing with alists?
TIA,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
- How to delete all nil properties from a plist?,
Marcin Borkowski <=
- Re: How to delete all nil properties from a plist?, Marcin Borkowski, 2015/08/01
- Re: How to delete all nil properties from a plist?, Emanuel Berg, 2015/08/01
- Message not available
- Message not available
- Re: How to delete all nil properties from a plist?, Pascal J. Bourguignon, 2015/08/02
- Re: How to delete all nil properties from a plist?, Emanuel Berg, 2015/08/05
- Message not available
- Re: How to delete all nil properties from a plist?, Pascal J. Bourguignon, 2015/08/05
- Re: How to delete all nil properties from a plist?, Emanuel Berg, 2015/08/05