Streams


Stream

Namespace: Nessos.Streams
Attributes:
[<RequireQualifiedAccess>]

Provides basic operations on Streams.

Nested types and modules

ModuleDescription
Internals

Functions and values

Function or valueDescription
Stream.cache(source)
Signature: source:Stream<'T> -> Stream<'T>
Type parameters: 'T

Creates a cached version of the input stream.

Stream.cast(source)
Signature: source:IEnumerable -> Stream<'T>
Type parameters: 'T

Wraps an IEnumerable as a stream.

Stream.choose chooser stream
Signature: chooser:('T -> 'R option) -> stream:Stream<'T> -> Stream<'R>
Type parameters: 'T, 'R

Applies the given function to each element of the stream and returns the stream comprised of the results for each element where the function returns Some with some value.

Stream.collect f stream
Signature: f:('T -> Stream<'R>) -> stream:Stream<'T> -> Stream<'R>
Type parameters: 'T, 'R

Transforms each element of the input stream to a new stream and flattens its elements.

Stream.concat(streams)
Signature: streams:'?14111 -> Stream<'T>
Type parameters: '?14111, 'T

Concatenates a collection of streams.

Stream.countBy project stream
Signature: project:('T -> 'Key) -> stream:Stream<'T> -> Stream<'Key * int>
Type parameters: 'T, 'Key

Applies a key-generating function to each element of the input stream and yields a stream of unique keys and their frequency.

Stream.empty
Signature: Stream<'T>
Type parameters: 'T

The empty stream.

Stream.exists predicate stream
Signature: predicate:('T -> bool) -> stream:Stream<'T> -> bool
Type parameters: 'T

Tests if any element of the stream satisfies the given predicate.

Stream.filter predicate stream
Signature: predicate:('T -> bool) -> stream:Stream<'T> -> Stream<'T>
Type parameters: 'T

Filters the elements of the input stream.

Stream.find predicate stream
Signature: predicate:('T -> bool) -> stream:Stream<'T> -> 'T
Type parameters: 'T

Returns the first element for which the given function returns true. Raises KeyNotFoundException if no such element exists.

Stream.flatMap f stream
Signature: f:('T -> Stream<'R>) -> stream:Stream<'T> -> Stream<'R>
Type parameters: 'T, 'R

Transforms each element of the input stream to a new stream and flattens its elements.

Stream.fold folder state stream
Signature: folder:('State -> 'T -> 'State) -> state:'State -> stream:Stream<'T> -> 'State
Type parameters: 'State, 'T

Applies a function to each element of the stream, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN, then this function computes f (... (f s i0)...) iN.

Stream.foldBy(...)
Signature: projection:('T -> 'Key) -> folder:('State -> 'T -> 'State) -> init:(unit -> 'State) -> source:Stream<'T> -> Stream<'Key * 'State>
Type parameters: 'T, 'Key, 'State

Applies a state-updating function to a stream of inputs, grouped by key projection.

Stream.forall predicate stream
Signature: predicate:('T -> bool) -> stream:Stream<'T> -> bool
Type parameters: 'T

Tests if all elements of the stream satisfy the given predicate.

Stream.generateInfinite(generator)
Signature: generator:(unit -> 'T) -> Stream<'T>
Type parameters: 'T

Produces an infinite Stream by calling the given function.

Stream.groupBy projection source
Signature: projection:('T -> 'Key) -> source:Stream<'T> -> Stream<'Key * seq<'T>>
Type parameters: 'T, 'Key

Applies a key-generating function to each element of the input stream and yields a stream of unique keys and a sequence of all elements that have each key.

Stream.groupUntil(...)
Signature: inclusive:bool -> predicate:('T -> bool) -> source:Stream<'T> -> Stream<'T []>
Type parameters: 'T

Separates stream elements into groups until predicate is satisfied. Elements not satisfying the predicate are included as final element in grouping or discarded depending on the 'inclusive' parameter.

Stream.head(stream)
Signature: stream:Stream<'T> -> 'T
Type parameters: 'T

Returns the first element of the stream.

Stream.initInfinite(initializer)
Signature: initializer:(int -> 'T) -> Stream<'T>
Type parameters: 'T

Generates an infinite Stream which returns successive elements by calling the given function. Indexing starts at 0, and continues until Int32.MaxValue

Stream.isEmpty(stream)
Signature: stream:Stream<'T> -> bool
Type parameters: 'T

Returns true if the stream is empty and false otherwise.

Stream.iter f stream
Signature: f:('T -> unit) -> stream:Stream<'T> -> unit
Type parameters: 'T

Applies the given function to each element of the stream.

Stream.length(stream)
Signature: stream:Stream<'T> -> int
Type parameters: 'T

Returns the total number of elements of the stream.

Stream.map f stream
Signature: f:('T -> 'R) -> stream:Stream<'T> -> Stream<'R>
Type parameters: 'T, 'R

Transforms each element of the input stream.

Stream.mapi f stream
Signature: f:(int -> 'T -> 'R) -> stream:Stream<'T> -> Stream<'R>
Type parameters: 'T, 'R

Transforms each element of the input stream. The integer index passed to the function indicates the index (from 0) of element being transformed.

Stream.maxBy projection source
Signature: projection:('T -> 'Key) -> source:Stream<'T> -> 'T
Type parameters: 'T, 'Key

Locates the maximum element of the stream by given key.

Stream.minBy projection source
Signature: projection:('T -> 'Key) -> source:Stream<'T> -> 'T
Type parameters: 'T, 'Key

Locates the minimum element of the stream by given key.

Stream.ofArray(source)
Signature: source:'T [] -> Stream<'T>
Type parameters: 'T

Wraps array as a stream.

Stream.ofList(source)
Signature: source:'T list -> Stream<'T>
Type parameters: 'T

Wraps list as a stream.

Stream.ofResizeArray(source)
Signature: source:ResizeArray<'T> -> Stream<'T>
Type parameters: 'T

Wraps ResizeArray as a stream.

Stream.ofSeq(source)
Signature: source:seq<'T> -> Stream<'T>
Type parameters: 'T

Wraps seq as a stream.

Stream.ofSystemStreamByLine(stream)
Signature: stream:Stream -> Stream<string>

Produces a stream by sequentially reading a System.IO.Stream of text, splitting input by line separator.

Stream.ofTextFileByLine(path)
Signature: path:string -> Stream<string>

Produces a stream by sequentially reading a text file from given path. Text file entries are split by line separator.

Stream.pick chooser stream
Signature: chooser:('T -> 'R option) -> stream:Stream<'T> -> 'R
Type parameters: 'T, 'R

Applies the given function to successive elements, returning the first result where the function returns a Some value. Raises KeyNotFoundException when every item of the stream evaluates to None when the given function is applied.

Stream.scan folder state stream
Signature: folder:('State -> 'T -> 'State) -> state:'State -> stream:Stream<'T> -> Stream<'State>
Type parameters: 'State, 'T

Like Stream.fold, but computes on-demand and returns the stream of intermediate and final results

Stream.singleton(source)
Signature: source:'T -> Stream<'T>
Type parameters: 'T

Creates a singleton stream.

Stream.skip n stream
Signature: n:int -> stream:Stream<'T> -> Stream<'T>
Type parameters: 'T

Returns a stream that skips N elements of the input stream and then yields the remaining elements of the stream.

Stream.sortBy projection stream
Signature: projection:('T -> 'Key) -> stream:Stream<'T> -> Stream<'T>
Type parameters: 'T, 'Key

Applies a key-generating function to each element of the input stream and yields a stream ordered by keys.

Stream.sum(stream)
Signature: stream:Stream<^T> -> ^T
Type parameters: ^T

Returns the sum of the elements.

Stream.take n stream
Signature: n:int -> stream:Stream<'T> -> Stream<'T>
Type parameters: 'T

Returns the elements of the stream up to a specified count.

Stream.takeWhile pred stream
Signature: pred:('T -> bool) -> stream:Stream<'T> -> Stream<'T>
Type parameters: 'T

Returns the elements of the stream while the given predicate returns true.

Stream.toArray(stream)
Signature: stream:Stream<'T> -> 'T []
Type parameters: 'T

Creates an array from the given stream.

Stream.toResizeArray(stream)
Signature: stream:Stream<'T> -> ResizeArray<'T>
Type parameters: 'T

Creates an ResizeArray from the given stream.

Stream.toSeq(stream)
Signature: stream:Stream<'T> -> seq<'T>
Type parameters: 'T

Creates an Seq from the given stream.

Stream.tryFind predicate stream
Signature: predicate:('T -> bool) -> stream:Stream<'T> -> 'T option
Type parameters: 'T

Returns the first element for which the given function returns true. Returns None if no such element exists.

Stream.tryHead(stream)
Signature: stream:Stream<'T> -> 'T option
Type parameters: 'T

Returns the first element of the stream.

Stream.tryPick chooser stream
Signature: chooser:('T -> 'R option) -> stream:Stream<'T> -> 'R option
Type parameters: 'T, 'R

Applies the given function to successive elements, returning the first result where the function returns a Some value.

Stream.zipWith f first second
Signature: f:('T -> 'S -> 'R) -> first:Stream<'T> -> second:Stream<'S> -> Stream<'R>
Type parameters: 'T, 'S, 'R

Applies a specified function to the corresponding elements of two streams, producing a stream of the results.

Fork me on GitHub