mirror of
https://github.com/fiddlerwoaroof/data-lens.git
synced 2025-11-08 10:16:32 +00:00
refactor(transducers): simplify list builder
This commit is contained in:
@ -127,22 +127,19 @@
|
||||
|
||||
(defmethod init ((it (eql 'list-builder)))
|
||||
(declare (optimize (speed 3)))
|
||||
(coerce (vector nil nil)
|
||||
'(simple-array list (2))))
|
||||
(let ((it (list nil)))
|
||||
(coerce (vector it it)
|
||||
'(simple-array list (2)))))
|
||||
(defmethod stepper ((it (eql 'list-builder)))
|
||||
(lambda (acc a)
|
||||
(declare (optimize (speed 3))
|
||||
(type (simple-array list (2)) acc))
|
||||
(if (elt acc 1)
|
||||
(let* ((to-build (elt acc 1)))
|
||||
(push a (cdr to-build))
|
||||
(setf (elt acc 1) (cdr to-build)))
|
||||
(let ((new (list a)))
|
||||
(setf (elt acc 0) new
|
||||
(elt acc 1) new)))
|
||||
acc))
|
||||
(defmethod unwrap ((it (eql 'list-builder)) obj)
|
||||
(elt obj 0))
|
||||
(cdr (elt obj 0)))
|
||||
|
||||
(defclass lazy-sequence ()
|
||||
((%next :initarg :next :reader next)))
|
||||
|
||||
Reference in New Issue
Block a user