unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to delete all nil properties from a plist?
@ 2015-08-01 22:03 Marcin Borkowski
  2015-08-01 22:11 ` Marcin Borkowski
       [not found] ` <mailman.7749.1438467076.904.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 24+ messages in thread
From: Marcin Borkowski @ 2015-08-01 22:03 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list

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



^ permalink raw reply	[flat|nested] 24+ messages in thread
[parent not found: <mailman.7748.1438466648.904.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2015-08-09  2:28 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-01 22:03 How to delete all nil properties from a plist? Marcin Borkowski
2015-08-01 22:11 ` Marcin Borkowski
2015-08-02  1:32   ` Emanuel Berg
     [not found]   ` <mailman.7753.1438479312.904.help-gnu-emacs@gnu.org>
2015-08-02  1:36     ` Pascal J. Bourguignon
2015-08-02  1:50       ` Emanuel Berg
2015-08-02  3:55       ` Rusi
2015-08-02 16:21         ` Pascal J. Bourguignon
     [not found]       ` <mailman.7754.1438480361.904.help-gnu-emacs@gnu.org>
2015-08-02 16:24         ` Pascal J. Bourguignon
2015-08-05 23:08           ` Emanuel Berg
     [not found]           ` <mailman.7864.1438816202.904.help-gnu-emacs@gnu.org>
2015-08-05 23:30             ` Pascal J. Bourguignon
2015-08-05 23:49               ` Emanuel Berg
2015-08-06  0:30               ` Emanuel Berg
2015-08-06  1:05                 ` John Mastro
2015-08-06  1:07                   ` John Mastro
     [not found]               ` <mailman.7867.1438818687.904.help-gnu-emacs@gnu.org>
2015-08-06  2:32                 ` Pascal J. Bourguignon
2015-08-07 22:21                   ` Emanuel Berg
     [not found]               ` <mailman.7869.1438821124.904.help-gnu-emacs@gnu.org>
2015-08-06  2:40                 ` Pascal J. Bourguignon
2015-08-07 22:32                   ` Emanuel Berg
     [not found]                   ` <mailman.7963.1438986782.904.help-gnu-emacs@gnu.org>
2015-08-08  3:56                     ` Pascal J. Bourguignon
2015-08-09  1:34                       ` Emanuel Berg
     [not found]                       ` <mailman.7996.1439084206.904.help-gnu-emacs@gnu.org>
2015-08-09  2:18                         ` Pascal J. Bourguignon
2015-08-09  2:28                           ` Emanuel Berg
     [not found] ` <mailman.7749.1438467076.904.help-gnu-emacs@gnu.org>
2015-08-01 23:46   ` Pascal J. Bourguignon
     [not found] <mailman.7748.1438466648.904.help-gnu-emacs@gnu.org>
2015-08-01 23:43 ` Pascal J. Bourguignon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).