[Top][All Lists]

[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."
   ((< (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

Question 2: how would I do the analogous thing with alists?


Marcin Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

reply via email to

[Prev in Thread] Current Thread [Next in Thread]