Subject: Re: lambda list question
From: rpw3@rpw3.org (Rob Warnock)
Date: Wed, 26 Mar 2008 05:55:52 -0500
Newsgroups: comp.lang.lisp
Message-ID: <nYqdnds0DtUltnfanZ2dnUVZ_umlnZ2d@speakeasy.net>
Pascal Costanza  <pc@p-cos.net> wrote:
+---------------
| Edi Weitz wrote:
| >"fairchild.anthony@gmail.com" <fairchild.anthony@gmail.com> wrote:
| >> This is exactly what I ended up doing, but I make a copy of keys
| >> before removing.
| > 
| > For removing the keys, this might be useful:
| >   http://groups.google.com/group/comp.lang.lisp/msg/2520fe9bc7749328
| 
| That's too complicated.
| (loop for (key value) on plist by #'cddr
|        when (member key keys-to-keep)
|        collect key collect value)
+---------------

Uh... But this assumes one knows KEYS-TO-KEEP! The original
problem statement gave a KEYS-TO-STRIP-OUT [not per se,
but implicitly, by naming them], not KEYS-TO-KEEP, with an
&ALLOW-OTHER-KEYS so *anything* could end up in the &REST list.
So I'd think you'd want to write it like this instead:

  (loop for (key value) on plist by #'cddr
         unless (member key keys-to-strip-out)
         collect key collect value)


-Rob

p.s. If KEYS-TO-STRIP-OUT were *huge*, one might want to use
a hash table for speed:

  (loop for (key value) on plist by #'cddr
         unless (gethash key keys-to-strip-out-table)
         collect key collect value)

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607