[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to delete all nil properties from a plist?
From: |
Pascal J. Bourguignon |
Subject: |
Re: How to delete all nil properties from a plist? |
Date: |
Sun, 02 Aug 2015 18:21:48 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Rusi <rustompmody@gmail.com> writes:
> 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...]
What's horrible is the ratio between the actual O(.) over the possible
O(.).
> BTW: Thanks for being civilized/cultured and using a non-ASCII character ²
> when it is appropriate. Vive la Unicode!
--
__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
- How to delete all nil properties from a plist?, Marcin Borkowski, 2015/08/01
- 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
- Re: How to delete all nil properties from a plist?, Emanuel Berg, 2015/08/05
- Re: How to delete all nil properties from a plist?, John Mastro, 2015/08/05
- Re: How to delete all nil properties from a plist?, John Mastro, 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/07
- Message not available
- Re: How to delete all nil properties from a plist?, Pascal J. Bourguignon, 2015/08/05