FSharpPlus


Seq Module

Additional operations on Seq

Functions and values

Function or value Description

Seq.apply f x

Full Usage: Seq.apply f x

Parameters:
    f : ('a -> 'b) seq - The seq of functions.
    x : 'a seq - The seq of values.

Returns: 'b seq A seq concatenating the results from applying each function to each value.

Applies a sequence of functions to a sequence of values and concatenates them.

f : ('a -> 'b) seq

The seq of functions.

x : 'a seq

The seq of values.

Returns: 'b seq

A seq concatenating the results from applying each function to each value.

Example

 > Seq.apply [double; triple] [1; 2; 3];;  
 val it : seq<int> = seq [2; 4; 6; 3; ...]
module Seq from Microsoft.FSharp.Collections
Multiple items
val double: value: 'T -> double (requires member op_Explicit)

--------------------
type double = System.Double

--------------------
type double<'Measure> = float<'Measure>
Multiple items
val seq: sequence: 'T seq -> 'T seq

--------------------
type 'T seq = System.Collections.Generic.IEnumerable<'T>
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int

Seq.bind mapping source

Full Usage: Seq.bind mapping source

Parameters:
    mapping : 'T -> 'U seq - A function to transform elements of the input sequence into the sequences that will then be concatenated.
    source : 'T seq - The input sequence.

Returns: 'U seq The result sequence.

Applies the given function to each element of the sequence and concatenates the results.

Remember sequence is lazy, effects are delayed until it is enumerated.This is the same as Seq.collect but the type of the mapping function is not flexible.

mapping : 'T -> 'U seq

A function to transform elements of the input sequence into the sequences that will then be concatenated.

source : 'T seq

The input sequence.

Returns: 'U seq

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.choosei mapping source

Full Usage: Seq.choosei mapping source

Parameters:
    mapping : int -> 'a -> 'b option - The mapping function, taking index and element as parameters.
    source : 'a seq - The input seq.

Returns: 'b seq Seq with values x for each List value where the function returns Some(x).

Choose with access to the index

mapping : int -> 'a -> 'b option

The mapping function, taking index and element as parameters.

source : 'a seq

The input seq.

Returns: 'b seq

Seq with values x for each List value where the function returns Some(x).

Seq.chunkBy projection source

Full Usage: Seq.chunkBy projection source

Parameters:
    projection : 'T -> 'Key - A function that transforms an element of the sequence into a comparable key.
    source : 'T seq - The input seq.

Returns: ('Key * ResizeArray<'T>) seq The resulting sequence of keys tupled with an array of matching values

Chunks the seq up into groups with the same projected key by applying the key-generating projection function to each element and yielding a sequence of keys tupled with values.

Each key is tupled with an array of all adjacent elements that match to the key, therefore keys are not unique but can't be adjacent as each time the key changes a new group is yield. The ordering of the original sequence is respected.

projection : 'T -> 'Key

A function that transforms an element of the sequence into a comparable key.

source : 'T seq

The input seq.

Returns: ('Key * ResizeArray<'T>) seq

The resulting sequence of keys tupled with an array of matching values

Seq.drop count source

Full Usage: Seq.drop count source

Parameters:
    count : int - The number of items to drop.
    source : 'b seq - The input sequence.

Returns: 'b seq The result sequence.

Returns a sequence that drops N elements of the original sequence and then yields the remaining elements of the sequence.

When count exceeds the number of elements in the sequence it returns an empty sequence instead of throwing an exception.

count : int

The number of items to drop.

source : 'b seq

The input sequence.

Returns: 'b seq

The result sequence.

Seq.findLastSliceIndex slice source

Full Usage: Seq.findLastSliceIndex slice source

Parameters:
    slice : 'b seq
    source : 'b seq

Returns: int The index of the slice.

Gets the index of the last occurrence of the specified slice in the source.

It is assumed that both the slice and the source are finite, otherwise it will not return forever. Both the slice and the source will always be iterated to the end.

slice : 'b seq
source : 'b seq
Returns: int

The index of the slice.

ArgumentException Thrown when the slice was not found in the sequence.

Seq.findSliceIndex slice source

Full Usage: Seq.findSliceIndex slice source

Parameters:
    slice : 'b seq
    source : 'b seq

Returns: int The index of the slice.

Gets the index of the first occurrence of the specified slice in the source.

It is assumed that 1) the slice is finite and 2) either the source is finite or actually contains the slice, otherwise it will not return forever. The slice will always be iterated to the end. The source will be iterated until the slice is found or it reaches the end.

slice : 'b seq
source : 'b seq
Returns: int

The index of the slice.

ArgumentException Thrown when the slice was not found in the sequence.

Seq.foldBack folder source state

Full Usage: Seq.foldBack folder source state

Parameters:
    folder : 'f -> 'g -> 'g - The function to update the state given the input elements.
    source : 'f seq - The input sequence.
    state : 'g - The initial state.

Returns: 'g

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

Note: this function has since been added to FSharp.Core. It will be removed in next major release of FSharpPlus.

folder : 'f -> 'g -> 'g

The function to update the state given the input elements.

source : 'f seq

The input sequence.

state : 'g

The initial state.

Returns: 'g

Seq.intercalate separator source

Full Usage: Seq.intercalate separator source

Parameters:
    separator : 'b seq
    source : 'c seq

Returns: 'b seq

Inserts a separator between each element in the source sequence.

separator : 'b seq
source : 'c seq
Returns: 'b seq

Seq.intersperse sep list

Full Usage: Seq.intersperse sep list

Parameters:
    sep : 'a
    list : 'a seq

Returns: 'a seq

Inserts a separator element between each element in the source seq. http://codebetter.com/matthewpodwysocki/2009/05/06/functionally-implementing-intersperse/

sep : 'a
list : 'a seq
Returns: 'a seq

Seq.lift2 f x1 x2

Full Usage: Seq.lift2 f x1 x2

Parameters:
    f : 'b -> 'c -> 'd
    x1 : 'b seq
    x2 : 'c seq

Returns: 'd seq

Combines all values from the first seq with the second, using the supplied mapping function.

f : 'b -> 'c -> 'd
x1 : 'b seq
x2 : 'c seq
Returns: 'd seq

Seq.lift3 f x1 x2 x3

Full Usage: Seq.lift3 f x1 x2 x3

Parameters:
    f : 'b -> 'c -> 'd -> 'e - Mapping function taking three element combination as input.
    x1 : 'd seq - First seq.
    x2 : 'b seq - Second seq.
    x3 : 'c seq - Third seq.

Returns: 'e seq Seq with values returned from mapping function.

Combines values from three seq and calls a mapping function on this combination.

f : 'b -> 'c -> 'd -> 'e

Mapping function taking three element combination as input.

x1 : 'd seq

First seq.

x2 : 'b seq

Second seq.

x3 : 'c seq

Third seq.

Returns: 'e seq

Seq with values returned from mapping function.

Seq.replace oldValue newValue source

Full Usage: Seq.replace oldValue newValue source

Parameters:
    oldValue : 'T seq
    newValue : 'T seq
    source : 'T seq

Returns: 'T seq

Replaces a subsequence of the source seq with the given replacement seq.

oldValue : 'T seq
newValue : 'T seq
source : 'T seq
Returns: 'T seq

Seq.replicate count initial

Full Usage: Seq.replicate count initial

Parameters:
    count : int - The number of elements to replicate.
    initial : 'g - The value to replicate

Returns: IEnumerable<'g> The generated sequence.

Creates a sequence by replicating the given initial value.

Note: this function has since been added to FSharp.Core. It will be removed in next major release of FSharpPlus.

count : int

The number of elements to replicate.

initial : 'g

The value to replicate

Returns: IEnumerable<'g>

The generated sequence.

Seq.split separators source

Full Usage: Seq.split separators source

Parameters:
    separators : 'b seq
    source : 'c seq

Returns: 'c seq seq

Creates a sequence of sequences by splitting the source sequence on any of the given separators.

separators : 'b seq
source : 'c seq
Returns: 'c seq seq

Seq.toIReadOnlyList source

Full Usage: Seq.toIReadOnlyList source

Parameters:
    source : 'a seq - The seq source

Returns: IReadOnlyList<'a> The seq converted to a System.Collections.Generic.IReadOnlyList

Converts a seq to an IReadOnlyList (from System.Collections.Generic).

source : 'a seq

The seq source

Returns: IReadOnlyList<'a>

The seq converted to a System.Collections.Generic.IReadOnlyList

Seq.tryFindLastSliceIndex slice source

Full Usage: Seq.tryFindLastSliceIndex slice source

Parameters:
    slice : 'b seq
    source : 'b seq

Returns: int option The index of the slice or None.

Gets the index of the last occurrence of the specified slice in the source. Returns None if not found.

It is assumed that both the slice and the source are finite, otherwise it will not return forever. Both the slice and the source will always be iterated to the end.

slice : 'b seq
source : 'b seq
Returns: int option

The index of the slice or None.

Seq.tryFindSliceIndex slice source

Full Usage: Seq.tryFindSliceIndex slice source

Parameters:
    slice : 'b seq
    source : 'b seq

Returns: int option The index of the slice or None.

Gets the index of the first occurrence of the specified slice in the source. Returns None if not found.

It is assumed that 1) the slice is finite and 2) either the source is finite or actually contains the slice, otherwise it will not return forever. The slice will always be iterated to the end. The source will be iterated until the slice is found or it reaches the end.

slice : 'b seq
source : 'b seq
Returns: int option

The index of the slice or None.