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 : seq<('a -> 'b)> - The seq of functions.
    x : seq<'a> - The seq of values.

Returns: seq<'b> 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 : seq<('a -> 'b)>

The seq of functions.

x : seq<'a>

The seq of values.

Returns: seq<'b>

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: seq<'T> -> seq<'T>

--------------------
type seq<'T> = 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 -> seq<'U> - A function to transform elements of the input sequence into the sequences that will then be concatenated.
    source : seq<'T> - The input sequence.

Returns: seq<'U> 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 -> seq<'U>

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

source : seq<'T>

The input sequence.

Returns: seq<'U>

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 : seq<'a> - The input seq.

Returns: seq<'b> 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 : seq<'a>

The input seq.

Returns: seq<'b>

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 : seq<'T> - The input seq.

Returns: seq<'Key * ResizeArray<'T>> 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 : seq<'T>

The input seq.

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

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 : seq<'b> - The input sequence.

Returns: seq<'b> 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 : seq<'b>

The input sequence.

Returns: seq<'b>

The result sequence.

Seq.findSliceIndex slice source

Full Usage: Seq.findSliceIndex slice source

Parameters:
    slice : seq<'b>
    source : seq<'b>

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 : seq<'b>
source : seq<'b>
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 : seq<'f> - 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 : seq<'f>

The input sequence.

state : 'g

The initial state.

Returns: 'g

Seq.intercalate separator source

Full Usage: Seq.intercalate separator source

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

Returns: seq<'b>

Inserts a separator between each element in the source sequence.

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

Seq.intersperse sep list

Full Usage: Seq.intersperse sep list

Parameters:
    sep : 'a
    list : seq<'a>

Returns: seq<'a>

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

sep : 'a
list : seq<'a>
Returns: seq<'a>

Seq.lift2 f x1 x2

Full Usage: Seq.lift2 f x1 x2

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

Returns: seq<'d>

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

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

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 : seq<'d> - First seq.
    x2 : seq<'b> - Second seq.
    x3 : seq<'c> - Third seq.

Returns: seq<'e> 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 : seq<'d>

First seq.

x2 : seq<'b>

Second seq.

x3 : seq<'c>

Third seq.

Returns: seq<'e>

Seq with values returned from mapping function.

Seq.replace oldValue newValue source

Full Usage: Seq.replace oldValue newValue source

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

Returns: seq<'T>

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

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

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 : seq<'b>
    source : seq<'c>

Returns: seq<seq<'c>>

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

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

Seq.toIReadOnlyList source

Full Usage: Seq.toIReadOnlyList source

Parameters:
    source : seq<'a> - 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 : seq<'a>

The seq source

Returns: IReadOnlyList<'a>

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

Seq.tryFindSliceIndex slice source

Full Usage: Seq.tryFindSliceIndex slice source

Parameters:
    slice : seq<'b>
    source : seq<'b>

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 : seq<'b>
source : seq<'b>
Returns: int option

The index of the slice or None.