Next: , Previous: , Up: SRFI-171   [Contents][Index]


7.5.46.2 Applying Transducers

Scheme Procedure: list-transduce xform f lst
Scheme Procedure: list-transduce xform f identity lst

Initialize the transducer xform by passing the reducer f to it. If no identity is provided, f runs without arguments to return the reducer identity. It then reduces over lst using the identity as the seed.

If one of the transducers finishes early (such as ttake or tdrop), it communicates this by returning a reduced value, which in the guile implementation is just a value wrapped in a SRFI 9 record type named “reduced”. If such a value is returned by the transducer, list-transduce must stop execution and return an unreduced value immediately.

Scheme Procedure: vector-transduce xform f vec
Scheme Procedure: vector-transduce xform f identity vec
Scheme Procedure: string-transduce xform f str
Scheme Procedure: string-transduce xform f identity str
Scheme Procedure: bytevector-u8-transduce xform f bv
Scheme Procedure: bytevector-u8-transduce xform f identity bv
Scheme Procedure: generator-transduce xform f gen
Scheme Procedure: generator-transduce xform f identity gen

Same as list-transduce, but for vectors, strings, u8-bytevectors and SRFI-158-styled generators respectively.

Scheme Procedure: port-transduce xform f reader
Scheme Procedure: port-transduce xform f reader port
Scheme Procedure: port-transduce xform f identity reader port

Same as list-reduce but for ports. Called without a port, it reduces over the results of applying reader until the EOF-object is returned, presumably to read from current-input-port. With a port reader is applied to port instead of without any arguments. If identity is provided, that is used as the initial identity in the reduction.


Next: , Previous: , Up: SRFI-171   [Contents][Index]