Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ported Arnesi's #'MAKE-COLLECTOR

  • Loading branch information...
commit 355efb73b14cb09e45de0563631ee933fbc75f0b 1 parent 848c524
@adlai authored
Showing with 27 additions and 1 deletion.
  1. +2 −1  src/package.lisp
  2. +25 −0 src/utils.lisp
View
3  src/package.lisp
@@ -2,7 +2,8 @@
(defpackage :Eos
(:use :common-lisp :it.bese.arnesi)
- (:shadow #:ensure-list #:aif #:partitionx #:with-unique-names #:list-match-case)
+ (:shadow #:ensure-list #:aif #:make-collector #:partitionx
+ #:with-unique-names #:list-match-case)
(:export ;; creating tests and test-suites
#:make-suite
#:def-suite
View
25 src/utils.lisp
@@ -14,6 +14,31 @@
`(let ((it ,test))
(if it ,true ,false)))
+;;; This is taken from Arnesi's src/accumulation.lisp, and is way
+;;; too complicated for its simple use here.
+
+(defun make-collector (&optional initial-value)
+ "Create a collector function.
+
+A Collector function will collect, into a list, all the values
+passed to it in the order in which they were passed. If the
+callector function is called without arguments it returns the
+current list of values."
+ (let ((value initial-value)
+ (cdr (last initial-value)))
+ (lambda (&rest items)
+ (if items
+ (progn
+ (if value
+ (if cdr
+ (setf (cdr cdr) items
+ cdr (last items))
+ (setf cdr (last items)))
+ (setf value items
+ cdr (last items)))
+ items)
+ value))))
+
;;; This is taken from Arnesi's src/list.lisp, and partitions
;;; a list into separate parts using predicate lambdas
Please sign in to comment.
Something went wrong with that request. Please try again.