From 6168ffc43adb4360a6d5196c7cd78ddd533638bf Mon Sep 17 00:00:00 2001 From: Nicholas Coltharp Date: Wed, 1 Jan 2025 05:26:22 -0800 Subject: [PATCH] fix: `t-once` doesn't add to an empty stream Also fixes: `t-once` doesn't add `nil` to any stream. --- transducers.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/transducers.el b/transducers.el index b882811..5b66019 100644 --- a/transducers.el +++ b/transducers.el @@ -1026,16 +1026,18 @@ This requires a sequence of HEADERS to match keys by." #\'t-cons (t-ints 1)) => (hi 11 12)" (lambda (reducer) - (let ((item item)) + (let ((item (list item))) (lambda (result &rest inputs) - (if inputs (if item - (let ((res (funcall reducer result item))) - (if (t-reduced-p res) - res - (progn (setq item nil) - (apply reducer res inputs)))) - (apply reducer result inputs)) - (funcall reducer result)))))) + (if item (let ((res (funcall reducer result (car item)))) + (if (t-reduced-p res) + res + (setq item nil) + (if inputs + (apply reducer res inputs) + (funcall reducer res)))) + (if inputs + (apply reducer result inputs) + (funcall reducer result))))))) ;; (t-transduce (t-comp (t-filter (lambda (n) (> n 10))) ;; (t-once 'hi)