feat: add collecting transducer to accumulate partial sums

This commit is contained in:
Edward
2021-01-04 02:01:19 -08:00
parent e08fccfe1b
commit d0e894f739
3 changed files with 34 additions and 17 deletions

View File

@ -86,6 +86,18 @@
(funcall rf it last)
it)))))))
(defun collecting (collector)
(lambda (rf)
(let (sofar)
(transducer-lambda
((acc next)
(if sofar
(setf sofar (funcall collector sofar next))
(setf sofar next))
(funcall rf acc sofar))))))
(defun deduping (&optional (test 'eql))
(compressing-runs :test test))