help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to delete all nil properties from a plist?


From: Rusi
Subject: Re: How to delete all nil properties from a plist?
Date: Sat, 1 Aug 2015 20:55:24 -0700 (PDT)
User-agent: G2/1.0

On Sunday, August 2, 2015 at 7:06:24 AM UTC+5:30, Pascal J. Bourguignon wrote:
> Emanuel Berg writes:
> 
> > Marcin Borkowski writes:
> >
> >>> 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:
> >
> > Try this:
> >
> > (require 'cl)
> >
> > (defun plist-drop-nil-props (l)
> >   (let((new)
> >        (prop nil) )
> >     (cl-loop for x in l
> >              do (if (or (setq prop (not prop)) x)
> >                     (setq new (append new (list x)))
> >                   (setq new (butlast new))))
> >     new))
> 
> This is horrible. Again, you can't prevent yourself writing O(n²) code
> when O(n) would do perfectly.

Hey Pascal!
If O(n²) is 'horrible' what is O(n³)? And O(n⁴) ?
And the stuff in NP?
[I suppose the french lexicon has many adjectives...]

BTW: Thanks for being civilized/cultured and using a non-ASCII character ²
when it is appropriate. Vive la Unicode!


reply via email to

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