Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: t-once doesn't add to an empty stream or add nil to any stream #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions transducers.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down