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


7.5.46.5 Helper functions for writing transducers

These functions are in the (srfi srfi-171 meta) module and are only usable when you want to write your own transducers.

Scheme Procedure: reduced value

Wraps a value in a <reduced> container, signalling that the reduction should stop.

Scheme Procedure: reduced? value

Returns #t if value is a <reduced> record.

Scheme Procedure: unreduce reduced-container

Returns the value in reduced-container.

Scheme Procedure: ensure-reduced value

Wraps value in a <reduced> container if it is not already reduced.

Scheme Procedure: preserving-reduced reducer

Wraps reducer in another reducer that encapsulates any returned reduced value in another reduced container. This is useful in places where you re-use a reducer with [collection]-reduce. If the reducer returns a reduced value, [collection]-reduce unwraps it. Unless handled, this leads to the reduction continuing.

Scheme Procedure: list-reduce f identity lst

The reducing function used internally by list-transduce. f is a reducer as returned by a transducer. identity is the identity (sometimes called "seed") of the reduction. lst is a list. If f returns a reduced value, the reduction stops immediately and the unreduced value is returned.

Scheme Procedure: vector-reduce f identity vec

The vector version of list-reduce.

Scheme Procedure: string-reduce f identity str

The string version of list-reduce.

Scheme Procedure: bytevector-u8-reduce f identity bv

The bytevector-u8 version of list-reduce.

Scheme Procedure: port-reduce f identity reader port

The port version of list-reduce. It reduces over port using reader until reader returns the EOF object.

Scheme Procedure: generator-reduce f identity gen

The generator version of list-reduce. It reduces over gen until it returns the EOF object


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