[alexandria-devel] remove-from-plist

Attila Lendvai attila.lendvai at gmail.com
Tue Mar 11 14:35:41 UTC 2008


>  I would also remove the FIXME, on grounds that if plists are long
>  enough for that to matter, one shouldn't be using them anyway.


i'll remove the FIXME, but sticking to my conventions, i'll leave the
(searchable) comment there if somebody is bored and looking for things
to do... :)


>  (defun remove-from-plist (plist &rest keys)
>    (loop for (key value) on plist by #'cddr
>          unless (member key keys :test #'eq)
>          collect key and collect value))
>
>  (defun remove-from-plist (plist &rest keys)
>    (loop for (key . rest) on plist by #'cddr
>          do (assert rest () "Expected a proper plist, got ~S" plist)
>          unless (member key keys :test #'eq)
>          collect key and collect (first rest)))


thanks, looks better! in the absence of  any other comments, i'll push
this second variant eventually.


>  (defun remove-from-plist (plist &rest keys)
>    (loop with last = t
>          for (key . rest) on plist by #'cddr
>          do (setf last rest)
>          unless (member key keys :test #'eq)
>          collect key and collect (first rest)
>          finally (assert last () "Expected a proper plist, got ~S"
>  plist)))

-- 
 attila



More information about the alexandria-devel mailing list