Shorthand form for ZTransducer.identity.
Shorthand form for ZTransducer.identity. Use as:
ZTransducer[Int].filter(_ % 2 != 0)
Creates a transducer accumulating incoming values into lists of maximum size n
.
Creates a transducer accumulating incoming values into maps of up to n
keys.
Creates a transducer accumulating incoming values into maps of up to n
keys. Elements
are mapped to keys using the function key
; elements mapped to the same key will
be merged with the function f
.
Creates a transducer accumulating incoming values into sets of maximum size n
.
Accumulates incoming elements into a list as long as they verify predicate p
.
Accumulates incoming elements into a list as long as they verify effectful predicate p
.
Creates a transducer that always dies with the specified exception.
Creates a transducer that starts consuming values as soon as one fails
the predicate p
.
Creates a transducer that starts consuming values as soon as one fails
the effectful predicate p
.
Creates a transducer that always fails with the specified failure.
Creates a transducer by folding over a structure of type O
for as long as
contFn
results in true
.
Creates a transducer by folding over a structure of type O
for as long as
contFn
results in true
. The transducer will emit a value when contFn
evaluates to false
and then restart the folding.
Creates a transducer by folding over a structure of type O
.
Creates a transducer by folding over a structure of type O
. The transducer will
fold the inputs until the stream ends, resulting in a stream with one element.
Creates a transducer by effectfully folding over a structure of type O
.
Creates a transducer by effectfully folding over a structure of type O
. The transducer will
fold the inputs until the stream ends, resulting in a stream with one element.
Creates a sink by effectfully folding over a structure of type S
.
Creates a transducer that folds elements of type I
into a structure
of type O
until max
elements have been folded.
Creates a transducer that folds elements of type I
into a structure
of type O
until max
elements have been folded.
Like foldWeighted, but with a constant cost function of 1.
Creates a transducer that effectfully folds elements of type I
into a structure
of type O
until max
elements have been folded.
Creates a transducer that effectfully folds elements of type I
into a structure
of type O
until max
elements have been folded.
Like foldWeightedM, but with a constant cost function of 1.
Creates a transducer that folds elements of type I
into a structure
of type O
, until max
worth of elements (determined by the costFn
)
have been folded.
Creates a transducer that folds elements of type I
into a structure
of type O
, until max
worth of elements (determined by the costFn
)
have been folded.
Elements that have an individual cost larger than max
will
force the transducer to cross the max
cost. See foldWeightedDecompose
for a variant that can handle these cases.
Creates a transducer that folds elements of type I
into a structure
of type O
, until max
worth of elements (determined by the costFn
)
have been folded.
Creates a transducer that folds elements of type I
into a structure
of type O
, until max
worth of elements (determined by the costFn
)
have been folded.
The decompose
function will be used for decomposing elements that
cause an O
aggregate to cross max
into smaller elements. For
example:
Stream(1, 5, 1) .aggregate( ZTransducer .foldWeightedDecompose(List[Int]())((i: Int) => i.toLong, 4, (i: Int) => Chunk(i - 1, 1)) { (acc, el) => el :: acc } .map(_.reverse) ) .runCollect
The stream would emit the elements List(1), List(4), List(1, 1)
.
Be vigilant with this function, it has to generate "simpler" values
or the fold may never end. A value is considered indivisible if
decompose
yields the empty chunk or a single-valued chunk. In
these cases, there is no other choice than to yield a value that
will cross the threshold.
The foldWeightedDecomposeM allows the decompose function
to return a ZIO
value, and consequently it allows the transducer
to fail.
Creates a transducer that effectfully folds elements of type I
into a structure
of type S
, until max
worth of elements (determined by the costFn
) have
been folded.
Creates a transducer that effectfully folds elements of type I
into a structure
of type S
, until max
worth of elements (determined by the costFn
) have
been folded.
The decompose
function will be used for decomposing elements that
cause an S
aggregate to cross max
into smaller elements. Be vigilant with
this function, it has to generate "simpler" values or the fold may never end.
A value is considered indivisible if decompose
yields the empty chunk or a
single-valued chunk. In these cases, there is no other choice than to yield
a value that will cross the threshold.
See foldWeightedDecompose for an example.
Creates a transducer that effectfully folds elements of type I
into a structure
of type S
, until max
worth of elements (determined by the costFn
) have
been folded.
Creates a transducer that effectfully folds elements of type I
into a structure
of type S
, until max
worth of elements (determined by the costFn
) have
been folded.
Elements that have an individual cost larger than max
will
force the transducer to cross the max
cost. See foldWeightedDecomposeM
for a variant that can handle these cases.
Creates a transducer that always evaluates the specified effect.
Creates a transducer that purely transforms incoming values.
Creates a transducer that effectfully transforms incoming values.
Creates a transducer from a chunk processing function.
Creates a transducer that returns the first element of the stream, if it exists.
The identity transducer.
The identity transducer. Passed elements through.
Creates a transducer that returns the last element of the stream, if it exists.
Splits strings on newlines.
Splits strings on newlines. Handles both Windows newlines (\r\n
) and UNIX newlines (\n
).
Splits strings on a delimiter.
Decodes chunks of UTF-8 bytes into strings.
Decodes chunks of UTF-8 bytes into strings.
This transducer uses the String constructor's behavior when handling malformed byte sequences.