lists.lisp - clic - Clic is an command line interactive client for gopher writt… | |
git clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
lists.lisp (944B) | |
--- | |
1 (in-package :alexandria-2) | |
2 | |
3 (defun delete-from-plist* (plist &rest keys) | |
4 "Just like REMOVE-FROM-PLIST, but this version may destructively modif… | |
5 provided PLIST. | |
6 The second return value is an alist of the removed items, in unspecified… | |
7 ;; TODO: a plist? | |
8 (declare (optimize speed)) | |
9 (loop with head = plist | |
10 with tail = nil ; a nil tail means an empty result so far | |
11 with kept = () | |
12 for (key . rest) on plist by #'cddr | |
13 do (assert rest () "Expected a proper plist, got ~S" plist) | |
14 (if (member key keys :test #'eq) | |
15 ;; skip over this pair | |
16 (let ((next (cdr rest))) | |
17 (push (cons key (car rest)) | |
18 kept) | |
19 (if tail | |
20 (setf (cdr tail) next) | |
21 (setf head next))) | |
22 ;; keep this pair | |
23 (setf tail rest)) | |
24 finally (return (values head kept)))) |