From 9013ada754a1edb12f6157a3a2b9316be7bd987c Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 1 Jun 2006 16:26:31 +0100 Subject: [PATCH] collect: New functions collect-append and collect-nconc. --- collect.lisp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/collect.lisp b/collect.lisp index 219f351..359780c 100644 --- a/collect.lisp +++ b/collect.lisp @@ -71,4 +71,19 @@ (setf (cdar ,name) ,x) (setf (car ,name) nil))) +(defmacro collect-append (list &optional (name *collecting-anon-list-name*)) + "Append LIST to the tail of `collecting' list NAME. This obviously + involves copying LIST." + (with-gensyms item + `(dolist (,item ,list) + (collect ,item ,name)))) + +(defmacro collect-nconc (list &optional (name *collecting-anon-list-name*)) + "Attach LIST to the tail of `collecting' list NAME. This will involve + destroying LIST if anything else gets collected afterwards." + (let*/gensyms list + `(when ,list + (setf (cdar ,name) ,list) + (setf (car ,name) (last ,list))))) + ;;;----- That's all, folks -------------------------------------------------- -- 2.11.0