Returns a transducer that applies proc to all values. Stateless.
Returns a transducer that removes values for which pred? returns #f.
Returns a transducer that removes values for which pred? returns non-#f.
The same as
(compose (tmap proc) (tfilter values)). Stateless.
The argument mapping is an association list (using
to compare keys), a hash-table, a one-argument procedure taking one
argument and either producing that same argument or a replacement value.
Returns a transducer which checks for the presence of any value passed through it in mapping. If a mapping is found, the value of that mapping is returned, otherwise it just returns the original value.
Does not keep internal state, but modifying the mapping while it’s in use by treplace is an error.
Returns a transducer that discards the first n values.
Returns a transducer that discards all values and stops the transduction after the first n values have been let through. Any subsequent values are ignored.
Returns a transducer that discards the the first values for which pred? returns true.
Returns a transducer that stops the transduction after pred? has
returned #f. Any subsequent values are ignored and the last successful
value is returned. retf is a function that gets called whenever
pred? returns false. The arguments passed are the result so far
and the input for which pred? returns
#f. The default function is
(lambda (result input) result).
tconcatenate is a transducer that concatenates the content of each value (that must be a list) into the reduction.
(list-transduce tconcatenate rcons '((1 2) (3 4 5) (6 (7 8) 9))) ⇒ (1 2 3 4 5 6 (7 8) 9)
The same as
(compose (tmap proc) tconcatenate).
tflatten is a transducer that flattens an input consisting of lists.
(list-transduce tflatten rcons '((1 2) 3 (4 (5 6) 7 8) 9) ⇒ (1 2 3 4 5 6 7 8 9)
Returns a transducer that removes any directly following duplicate
elements. The default equality-predicate is
Returns a transducer that removes any subsequent duplicate elements
compared using equality-predicate. The default
Returns a transducer that groups n inputs in lists of n elements. When the transduction stops, it flushes any remaining collection, even if it contains fewer than n elements.
Returns a transducer that groups inputs in lists by whenever
(pred? input) changes value.
Returns a transducer which interposes value between each value
and the next. This does not compose gracefully with transducers like
ttake, as you might end up ending the transduction on
Returns a transducer that indexes values passed through it, starting at
start, which defaults to 0. The indexing is done through cons
(index . input).
(list-transduce (tenumerate 1) rcons (list 'first 'second 'third)) ⇒ ((1 . first) (2 . second) (3 . third))
Returns a transducer that can be used to log or print values and
results. The result of the logger procedure is discarded. The
default logger is
(lambda (result input) (write input)
These transducers are available in the
(srfi srfi-171 gnu)
library, and are provided outside the standard described by the SRFI-171
A batching transducer that accumulates results using reducer or
((transducer) reducer) until it returns a reduced value. This can
be used to generalize something like
;; This behaves exactly like (tsegment 4). (list-transduce (tbatch (ttake 4) rcons) rcons (iota 10)) ⇒ ((0 1 2 3) (4 5 6 7) (8 9))
A folding transducer that yields the result of
value), saving it’s result between iterations.
(list-transduce (tfold +) rcons (iota 10)) ⇒ (0 1 3 6 10 15 21 28 36 45)