chiark
/
gitweb
/
~mdw
/
lisp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
9d3ccec
)
collect: Whitespace rearrangement.
author
Mark Wooding
<mdw@distorted.org.uk>
Sun, 23 Apr 2006 00:57:42 +0000
(
01:57
+0100)
committer
Mark Wooding
<mdw@distorted.org.uk>
Sun, 23 Apr 2006 00:57:42 +0000
(
01:57
+0100)
collect.lisp
patch
|
blob
|
blame
|
history
diff --git
a/collect.lisp
b/collect.lisp
index 813707e54e04e7bd825262ce24e02a71bea1f2f4..5b48b206634d28951675e3c34d0fc93bc7ee9255 100644
(file)
--- a/
collect.lisp
+++ b/
collect.lisp
@@
-34,6
+34,7
@@
(defvar *collecting-anon-list-name* (gensym)
(defun make-collector ()
(let ((c (cons nil nil)))
(cons c c))))
(defun make-collector ()
(let ((c (cons nil nil)))
(cons c c))))
+
(defmacro collecting (vars &body body)
"Collect items into lists. The VARS are a list of collection variables --
their values are unspecified, except that they may be passed to `collect' and
(defmacro collecting (vars &body body)
"Collect items into lists. The VARS are a list of collection variables --
their values are unspecified, except that they may be passed to `collect' and
@@
-45,6
+46,7
@@
(defmacro collecting (vars &body body)
`(let ,(mapcar (lambda (v) `(,v (make-collector))) vars)
,@body
(values ,@(mapcar (lambda (v) `(cdar ,v)) vars))))
`(let ,(mapcar (lambda (v) `(,v (make-collector))) vars)
,@body
(values ,@(mapcar (lambda (v) `(cdar ,v)) vars))))
+
(defmacro with-collection (vars collection &body body)
"Collect items into lists VARS according to the form COLLECTION; then
evaluate BODY with VARS bound to those lists."
(defmacro with-collection (vars collection &body body)
"Collect items into lists VARS according to the form COLLECTION; then
evaluate BODY with VARS bound to those lists."
@@
-52,6
+54,7
@@
(defmacro with-collection (vars collection &body body)
,(listify vars)
(collecting ,vars ,collection)
,@body))
,(listify vars)
(collecting ,vars ,collection)
,@body))
+
(defmacro collect (x &optional (name *collecting-anon-list-name*))
"Add item X to the `collecting' list NAME (or *collecting-anon-list-name*
by default)."
(defmacro collect (x &optional (name *collecting-anon-list-name*))
"Add item X to the `collecting' list NAME (or *collecting-anon-list-name*
by default)."
@@
-59,6
+62,7
@@
(defmacro collect (x &optional (name *collecting-anon-list-name*))
`(let ((,tmp (cons ,x nil)))
(setf (cddr ,name) ,tmp)
(setf (cdr ,name) ,tmp))))
`(let ((,tmp (cons ,x nil)))
(setf (cddr ,name) ,tmp)
(setf (cdr ,name) ,tmp))))
+
(defmacro collect-tail (x &optional (name *collecting-anon-list-name*))
"Make item X be the tail of `collecting' list NAME (or
*collecting-anon-list-name* by default). It is an error to continue trying
(defmacro collect-tail (x &optional (name *collecting-anon-list-name*))
"Make item X be the tail of `collecting' list NAME (or
*collecting-anon-list-name* by default). It is an error to continue trying