Behaves like the identity function, but requests n
elements at a time from the input.
Behaves like the identity process, but emits no output until the source is exhausted.
Behaves like the identity process, but requests elements from its input in blocks that end whenever the predicate switches from true to false.
Outputs first value, and then any changed value from the last value.
Outputs first value, and then any changed value from the last value. eqf
is used for equality. *
Outputs chunks with a limited maximum size, splitting as necessary.
Outputs a list of chunks, the total size of all chunks is limited and split as necessary.
Output all chunks from the input Handle
.
Map/filter simultaneously.
Map/filter simultaneously. Calls collect
on each Chunk
in the stream.
Emits the first element of the Stream for which the partial function is defined.
Skip the first element that matches the predicate.
Drop n
elements of the input, then echo the rest.
Drops the last element.
Drops the last element if the predicate evaluates to true.
Emits all but the last n
elements of the input.
Drop the elements of the input until the predicate p
fails, then echo the rest.
Emits true
as soon as a matching element is received, else false
if no input matches
Emit only inputs which match the supplied predicate.
Emits the first input (if any) which matches the supplied predicate, to the output of the returned Pull
Folds all inputs using an initial value z
and supplied binary operator,
and emits a single element stream.
Folds all inputs using the supplied binary operator, and emits a single-element stream, or the empty stream if the input is empty.
Emits a single true
value if all input matches the predicate.
Emits a single true
value if all input matches the predicate.
Halts with false
as soon as a non-matching element is received.
Write all inputs to the output of the returned Pull
.
Emits the specified separator between every pair of elements in the source stream.
Return the last element of the input Handle
, if nonempty.
Return the last element of the input Handle
if nonempty, otherwise li.
Write all inputs to the output of the returned Pull
, transforming elements using f
.
Write all inputs to the output of the returned Pull
, transforming elements using f
.
Works in a chunky fashion and creates a Chunk.indexedSeq
for each mapped chunk.
Maps a running total according to S
and the input with the function f
.
Maps a running total according to S
and the input with the function f
.
scala> Stream("Hello", "World") | .mapAccumulate(0)((l, s) => (l + s.length, s.head)).toVector res0: Vector[(Int, Char)] = Vector((5,H), (10,W))
Output a transformed version of all chunks from the input Handle
.
Behaves like id
, but starts fetching the next chunk before emitting the current,
enabling processing on either side of the prefetch
to run in parallel.
Alias for pipe.fold1
Rethrow any Left(err)
.
Rethrow any Left(err)
. Preserves chunkiness.
Left fold which outputs all intermediate results.
Left fold which outputs all intermediate results. Example:
Stream(1,2,3,4) through pipe.scan(0)(_ + _) == Stream(0,1,3,6,10)
.
More generally:
Stream().scan(z)(f) == Stream(z)
Stream(x1).scan(z)(f) == Stream(z, f(z,x1))
Stream(x1,x2).scan(z)(f) == Stream(z, f(z,x1), f(f(z,x1),x2))
etc
Works in a chunky fashion, and creates a Chunk.indexedSeq
for each converted chunk.
Like pipe.scan
, but uses the first element of the stream as the seed.
Emit the given values, then echo the rest of the input.
Groups inputs in fixed size chunks by passing a "sliding window"
of size n
over them.
Groups inputs in fixed size chunks by passing a "sliding window"
of size n
over them. If the input contains less than or equal to
n
elements, only one chunk of this size will be emitted.
scala> Stream(1, 2, 3, 4).sliding(2).toList res0: List[Chunk[Int]] = List(Chunk(1, 2), Chunk(2, 3), Chunk(3, 4))
IllegalArgumentException
if n
<= 0
Break the input into chunks where the delimiter matches the predicate.
Break the input into chunks where the delimiter matches the predicate. The delimiter does not appear in the output. Two adjacent delimiters in the input result in an empty chunk in the output.
Writes the sum of all input elements, or zero if the input is empty.
Emits all elements of the input except the first one.
Emit the first n
elements of the input Handle
and return the new Handle
.
Emits the last n
elements of the input.
Like takeWhile
, but emits the first value which tests false.
Emit the longest prefix of the input for which all elements test true according to f
.
Halt the input stream at the first None
.
Halt the input stream at the first None
.
scala> unNoneTerminate(Stream(Some(1), Some(2), None, Some(3), None)).toVector res0: Vector[Int] = Vector(1, 2)
Convert the input to a stream of solely 1-element chunks.
Groups inputs into separate Vector
objects of size n
.
Groups inputs into separate Vector
objects of size n
.
scala> Stream(1, 2, 3, 4, 5).vectorChunkN(2).toVector res0: Vector[Vector[Int]] = Vector(Vector(1, 2), Vector(3, 4), Vector(5))
Zip the elements of the input Handle
with its indices, and return the new Handle
Zip the elements of the input Handle
with its next element wrapped into Some
, and return the new Handle
.
Zip the elements of the input Handle
with its next element wrapped into Some
, and return the new Handle
.
The last element is zipped with None
.
Zip the elements of the input Handle
with its previous element wrapped into Some
, and return the new Handle
.
Zip the elements of the input Handle
with its previous element wrapped into Some
, and return the new Handle
.
The first element is zipped with None
.
Zip the elements of the input Handle
with its previous and next elements wrapped into Some
, and return the new Handle
.
Zip the elements of the input Handle
with its previous and next elements wrapped into Some
, and return the new Handle
.
The first element is zipped with None
as the previous element,
the last element is zipped with None
as the next element.
Zips the input with a running total according to S
, up to but not including the current element.
Zips the input with a running total according to S
, up to but not including the current element. Thus the initial
z
value is the first emitted to the output:
scala> Stream("uno", "dos", "tres", "cuatro").zipWithScan(0)(_ + _.length).toList res0: List[(String,Int)] = List((uno,0), (dos,3), (tres,6), (cuatro,10))
Zips the input with a running total according to S
, including the current element.
Zips the input with a running total according to S
, including the current element. Thus the initial
z
value is the first emitted to the output:
scala> Stream("uno", "dos", "tres", "cuatro").zipWithScan(0)(_ + _.length).toList res0: List[(String,Int)] = List((uno,0), (dos,3), (tres,6), (cuatro,10))