Recently Written · git

clic

MIRROR ONLY Gopher client with pretty colours in Common Lisp

git clone https://github.com/equwal/clic

Log | Files | Refs


3rdparties/software/alexandria-20200427-git/alexandria-2/lists.lisp (944 bytes)

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 modify the
5 provided PLIST.
6 The second return value is an alist of the removed items, in unspecified order."
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))))