Transducers - inject reduced added by DeeEff on Mon Apr 3 01:44:06 2023

(import transducers)

(define (list-fold2 f sentinel lst) 
  (call/cc 
    (lambda (cc) 
      (foldl (lambda (k x) 
               (let ((y (f k x))) 
                 (if (reduced? y) 
                     (cc (unwrap y)) 
                     y))) 
              sentinel 
              lst))))

(transduce list-fold2
           values
           (collect-first)
           (list 'a 'b 'c))
; => 'a

(transduce foldl
           values
           (collect-first)
           (list 'a 'b 'c))
; => #<transducers.base#<reduced>>