Welcome to the CHICKEN Scheme pasting service

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>>

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
`call/cc' is a short name for which procedure?
Visually impaired? Let me spell it for you (wav file) download WAV