FSharp.Core


Seq Module

Contains operations for working with values of type seq.

Functions and values

Function or value Description

Seq.allPairs source1 source2

Full Usage: Seq.allPairs source1 source2

Parameters:
    source1 : seq<'T1> - The first sequence.
    source2 : seq<'T2> - The second sequence.

Returns: seq<'T1 * 'T2> The result sequence.

Returns a new sequence that contains all pairings of elements from the first and second sequences.

source1 : seq<'T1>

The first sequence.

source2 : seq<'T2>

The second sequence.

Returns: seq<'T1 * 'T2>

The result sequence.

ArgumentNullException Thrown when either of the input sequences is null.

Seq.append source1 source2

Full Usage: Seq.append source1 source2

Parameters:
    source1 : seq<'T> - The first sequence.
    source2 : seq<'T> - The second sequence.

Returns: seq<'T> The result sequence.

Wraps the two given enumerations as a single concatenated enumeration.

The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently.

source1 : seq<'T>

The first sequence.

source2 : seq<'T>

The second sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when either of the two provided sequences is null.

Seq.average source

Full Usage: Seq.average source

Parameters:
    source : seq<^T> - The input sequence.

Returns: ^T The average.

Returns the average of the elements in the sequence.

The elements are averaged using the + operator, DivideByInt method and Zero property associated with the element type.

source : seq<^T>

The input sequence.

Returns: ^T

The average.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input sequence has zero elements.

Seq.averageBy projection source

Full Usage: Seq.averageBy projection source

Parameters:
    projection : 'T -> ^U - A function applied to transform each element of the sequence.
    source : seq<'T> - The input sequence.

Returns: ^U The average.

Returns the average of the results generated by applying the function to each element of the sequence.

The elements are averaged using the + operator, DivideByInt method and Zero property associated with the generated type.

projection : 'T -> ^U

A function applied to transform each element of the sequence.

source : seq<'T>

The input sequence.

Returns: ^U

The average.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input sequence has zero elements.

Seq.cache source

Full Usage: Seq.cache source

Parameters:
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Returns a sequence that corresponds to a cached version of the input sequence.

The result sequence will have the same elements as the input sequence. The result can be enumerated multiple times. The input sequence will be enumerated at most once and only as far as is necessary. Caching a sequence is typically useful when repeatedly evaluating items in the original sequence is computationally expensive or if iterating the sequence causes side-effects that the user does not want to be repeated multiple times. Enumeration of the result sequence is thread safe in the sense that multiple independent IEnumerator values may be used simultaneously from different threads (accesses to the internal lookaside table are thread safe). Each individual IEnumerator is not typically thread safe and should not be accessed concurrently. Once enumeration of the input sequence has started, it's enumerator will be kept live by this object until the enumeration has completed. At that point, the enumerator will be disposed. The enumerator may be disposed and underlying cache storage released by converting the returned sequence object to type IDisposable, and calling the Dispose method on this object. The sequence object may then be re-enumerated and a fresh enumerator will be used.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.cast source

Full Usage: Seq.cast source

Parameters:
Returns: seq<'T> The result sequence.

Wraps a loosely-typed System.Collections sequence as a typed sequence.

The use of this function usually requires a type annotation. An incorrect type annotation may result in runtime type errors. Individual IEnumerator values generated from the returned sequence should not be accessed concurrently.

source : IEnumerable

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.choose chooser source

Full Usage: Seq.choose chooser source

Parameters:
    chooser : 'T -> 'U option - A function to transform items of type T into options of type U.
    source : seq<'T> - The input sequence of type T.

Returns: seq<'U> The result sequence.

Applies the given function to each element of the list. Return the list comprised of the results "x" for each element where the function returns Some(x).

The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently.

chooser : 'T -> 'U option

A function to transform items of type T into options of type U.

source : seq<'T>

The input sequence of type T.

Returns: seq<'U>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.chunkBySize chunkSize source

Full Usage: Seq.chunkBySize chunkSize source

Parameters:
    chunkSize : int - The maximum size of each chunk.
    source : seq<'T> - The input sequence.

Returns: seq<'T[]> The sequence divided into chunks.

Divides the input sequence into chunks of size at most chunkSize.

chunkSize : int

The maximum size of each chunk.

source : seq<'T>

The input sequence.

Returns: seq<'T[]>

The sequence divided into chunks.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when chunkSize is not positive.

Seq.collect mapping source

Full Usage: Seq.collect mapping source

Parameters:
    mapping : 'T -> 'Collection - 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 all the results.

Remember sequence is lazy, effects are delayed until it is enumerated.

mapping : 'T -> 'Collection

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.compareWith comparer source1 source2

Full Usage: Seq.compareWith comparer source1 source2

Parameters:
    comparer : 'T -> 'T -> int - A function that takes an element from each sequence and returns an int. If it evaluates to a non-zero value iteration is stopped and that value is returned.
    source1 : seq<'T> - The first input sequence.
    source2 : seq<'T> - The second input sequence.

Returns: int Returns the first non-zero result from the comparison function. If the end of a sequence is reached it returns a -1 if the first sequence is shorter and a 1 if the second sequence is shorter.

Compares two sequences using the given comparison function, element by element.

comparer : 'T -> 'T -> int

A function that takes an element from each sequence and returns an int. If it evaluates to a non-zero value iteration is stopped and that value is returned.

source1 : seq<'T>

The first input sequence.

source2 : seq<'T>

The second input sequence.

Returns: int

Returns the first non-zero result from the comparison function. If the end of a sequence is reached it returns a -1 if the first sequence is shorter and a 1 if the second sequence is shorter.

ArgumentNullException Thrown when either of the input sequences is null.

Seq.concat sources

Full Usage: Seq.concat sources

Parameters:
    sources : seq<'Collection> - The input enumeration-of-enumerations.

Returns: seq<'T> The result sequence.

Combines the given enumeration-of-enumerations as a single concatenated enumeration.

The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently.

sources : seq<'Collection>

The input enumeration-of-enumerations.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.contains value source

Full Usage: Seq.contains value source

Parameters:
    value : 'T - The value to locate in the input sequence.
    source : seq<'T> - The input sequence.

Returns: bool True if the input sequence contains the specified element; false otherwise.

Tests if the sequence contains the specified element.

value : 'T

The value to locate in the input sequence.

source : seq<'T>

The input sequence.

Returns: bool

True if the input sequence contains the specified element; false otherwise.

ArgumentNullException Thrown when the input sequence is null.

Seq.countBy projection source

Full Usage: Seq.countBy projection source

Parameters:
    projection : 'T -> 'Key - A function transforming each item of the input sequence into a key to be compared against the others.
    source : seq<'T> - The input sequence.

Returns: seq<'Key * int> The result sequence.

Applies a key-generating function to each element of a sequence and returns a sequence yielding unique keys and their number of occurrences in the original sequence.

Note that this function returns a sequence that digests the whole initial sequence as soon as that sequence is iterated. As a result this function should not be used with large or infinite sequences. The function makes no assumption on the ordering of the original sequence.

projection : 'T -> 'Key

A function transforming each item of the input sequence into a key to be compared against the others.

source : seq<'T>

The input sequence.

Returns: seq<'Key * int>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.delay generator

Full Usage: Seq.delay generator

Parameters:
    generator : unit -> seq<'T> - The generating function for the sequence.

Returns: seq<'T>

Returns a sequence that is built from the given delayed specification of a sequence.

The input function is evaluated each time an IEnumerator for the sequence is requested.

generator : unit -> seq<'T>

The generating function for the sequence.

Returns: seq<'T>

Seq.distinct source

Full Usage: Seq.distinct source

Parameters:
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Returns a sequence that contains no duplicate entries according to generic hash and equality comparisons on the entries. If an element occurs multiple times in the sequence then the later occurrences are discarded.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.distinctBy projection source

Full Usage: Seq.distinctBy projection source

Parameters:
    projection : 'T -> 'Key - A function transforming the sequence items into comparable keys.
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Returns a sequence that contains no duplicate entries according to the generic hash and equality comparisons on the keys returned by the given key-generating function. If an element occurs multiple times in the sequence then the later occurrences are discarded.

projection : 'T -> 'Key

A function transforming the sequence items into comparable keys.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.empty

Full Usage: Seq.empty

Returns: seq<'T> An empty sequence.

Creates an empty sequence.

Returns: seq<'T>

An empty sequence.

Seq.exactlyOne source

Full Usage: Seq.exactlyOne source

Parameters:
    source : seq<'T> - The input sequence.

Returns: 'T The only element of the sequence.

Returns the only element of the sequence.

source : seq<'T>

The input sequence.

Returns: 'T

The only element of the sequence.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input does not have precisely one element.

Seq.except itemsToExclude source

Full Usage: Seq.except itemsToExclude source

Parameters:
    itemsToExclude : seq<'T> - A sequence whose elements that also occur in the second sequence will cause those elements to be removed from the returned sequence.
    source : seq<'T> - A sequence whose elements that are not also in first will be returned.

Returns: seq<'T> A sequence that contains the set difference of the elements of two sequences.

Returns a new sequence with the distinct elements of the second sequence which do not appear in the first sequence, using generic hash and equality comparisons to compare values.

Note that this function returns a sequence that digests the whole of the first input sequence as soon as the result sequence is iterated. As a result this function should not be used with large or infinite sequences in the first parameter. The function makes no assumption on the ordering of the first input sequence.

itemsToExclude : seq<'T>

A sequence whose elements that also occur in the second sequence will cause those elements to be removed from the returned sequence.

source : seq<'T>

A sequence whose elements that are not also in first will be returned.

Returns: seq<'T>

A sequence that contains the set difference of the elements of two sequences.

ArgumentNullException Thrown when either of the two input sequences is null.

Seq.exists predicate source

Full Usage: Seq.exists predicate source

Parameters:
    predicate : 'T -> bool - A function to test each item of the input sequence.
    source : seq<'T> - The input sequence.

Returns: bool True if any result from the predicate is true; false otherwise.

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

The predicate is applied to the elements of the input sequence. If any application returns true then the overall result is true and no further elements are tested. Otherwise, false is returned.

predicate : 'T -> bool

A function to test each item of the input sequence.

source : seq<'T>

The input sequence.

Returns: bool

True if any result from the predicate is true; false otherwise.

ArgumentNullException Thrown when the input sequence is null.

Seq.exists2 predicate source1 source2

Full Usage: Seq.exists2 predicate source1 source2

Parameters:
    predicate : 'T1 -> 'T2 -> bool - A function to test each pair of items from the input sequences.
    source1 : seq<'T1> - The first input sequence.
    source2 : seq<'T2> - The second input sequence.

Returns: bool True if any result from the predicate is true; false otherwise.

Tests if any pair of corresponding elements of the input sequences satisfies the given predicate.

The predicate is applied to matching elements in the two sequences up to the lesser of the two lengths of the collections. If any application returns true then the overall result is true and no further elements are tested. Otherwise, false is returned. If one sequence is shorter than the other then the remaining elements of the longer sequence are ignored.

predicate : 'T1 -> 'T2 -> bool

A function to test each pair of items from the input sequences.

source1 : seq<'T1>

The first input sequence.

source2 : seq<'T2>

The second input sequence.

Returns: bool

True if any result from the predicate is true; false otherwise.

ArgumentNullException Thrown when either of the two input sequences is null.

Seq.filter predicate source

Full Usage: Seq.filter predicate source

Parameters:
    predicate : 'T -> bool - A function to test whether each item in the input sequence should be included in the output.
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Returns a new collection containing only the elements of the collection for which the given predicate returns "true". This is a synonym for Seq.where.

The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently. Remember sequence is lazy, effects are delayed until it is enumerated.

predicate : 'T -> bool

A function to test whether each item in the input sequence should be included in the output.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.find predicate source

Full Usage: Seq.find predicate source

Parameters:
    predicate : 'T -> bool - A function to test whether an item in the sequence should be returned.
    source : seq<'T> - The input sequence.

Returns: 'T The first element for which the predicate returns True.

Returns the first element for which the given function returns True.

predicate : 'T -> bool

A function to test whether an item in the sequence should be returned.

source : seq<'T>

The input sequence.

Returns: 'T

The first element for which the predicate returns True.

KeyNotFoundException Thrown if no element returns true when evaluated by the predicate
ArgumentNullException Thrown when the input sequence is null

Seq.findBack predicate source

Full Usage: Seq.findBack predicate source

Parameters:
    predicate : 'T -> bool - A function to test whether an item in the sequence should be returned.
    source : seq<'T> - The input sequence.

Returns: 'T The last element for which the predicate returns True.

Returns the last element for which the given function returns True.

This function digests the whole initial sequence as soon as it is called. As a result this function should not be used with large or infinite sequences.This function consumes the whole input sequence before returning the result.

predicate : 'T -> bool

A function to test whether an item in the sequence should be returned.

source : seq<'T>

The input sequence.

Returns: 'T

The last element for which the predicate returns True.

KeyNotFoundException Thrown if no element returns true when evaluated by the predicate
ArgumentNullException Thrown when the input sequence is null

Seq.findIndex predicate source

Full Usage: Seq.findIndex predicate source

Parameters:
    predicate : 'T -> bool - A function to test whether the index of a particular element should be returned.
    source : seq<'T> - The input sequence.

Returns: int The index of the first element for which the predicate returns True.

Returns the index of the first element for which the given function returns True.

predicate : 'T -> bool

A function to test whether the index of a particular element should be returned.

source : seq<'T>

The input sequence.

Returns: int

The index of the first element for which the predicate returns True.

KeyNotFoundException Thrown if no element returns true when evaluated by the predicate
ArgumentNullException Thrown when the input sequence is null

Seq.findIndexBack predicate source

Full Usage: Seq.findIndexBack predicate source

Parameters:
    predicate : 'T -> bool - A function to test whether the index of a particular element should be returned.
    source : seq<'T> - The input sequence.

Returns: int The index of the last element for which the predicate returns True.

Returns the index of the last element for which the given function returns True.

This function digests the whole initial sequence as soon as it is called. As a result this function should not be used with large or infinite sequences.

predicate : 'T -> bool

A function to test whether the index of a particular element should be returned.

source : seq<'T>

The input sequence.

Returns: int

The index of the last element for which the predicate returns True.

KeyNotFoundException Thrown if no element returns true when evaluated by the predicate
ArgumentNullException Thrown when the input sequence is null

Seq.fold folder state source

Full Usage: Seq.fold folder state source

Parameters:
    folder : 'State -> 'T -> 'State - A function that updates the state with each element from the sequence.
    state : 'State - The initial state.
    source : seq<'T> - The input sequence.

Returns: 'State The state object after the folding function is applied to each element of the sequence.

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

folder : 'State -> 'T -> 'State

A function that updates the state with each element from the sequence.

state : 'State

The initial state.

source : seq<'T>

The input sequence.

Returns: 'State

The state object after the folding function is applied to each element of the sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.fold2 folder state source1 source2

Full Usage: Seq.fold2 folder state source1 source2

Parameters:
    folder : 'State -> 'T1 -> 'T2 -> 'State - The function to update the state given the input elements.
    state : 'State - The initial state.
    source1 : seq<'T1> - The first input sequence.
    source2 : seq<'T2> - The second input sequence.

Returns: 'State The final state value.

Applies a function to corresponding elements of two collections, threading an accumulator argument through the computation.

The two sequences need not have equal lengths: when one sequence is exhausted any remaining elements in the other sequence are ignored. If the input function is f and the elements are i0...iN and j0...jN then computes f (... (f s i0 j0)...) iN jN.

folder : 'State -> 'T1 -> 'T2 -> 'State

The function to update the state given the input elements.

state : 'State

The initial state.

source1 : seq<'T1>

The first input sequence.

source2 : seq<'T2>

The second input sequence.

Returns: 'State

The final state value.

ArgumentNullException Thrown when the either of the input sequences is null.

Seq.foldBack folder source state

Full Usage: Seq.foldBack folder source state

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

Returns: 'State The state object after the folding function is applied to each element of the sequence.

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)...)

This function consumes the whole input sequence before returning the result.

folder : 'T -> 'State -> 'State

The function to update the state given the input elements.

source : seq<'T>

The input sequence.

state : 'State

The initial state.

Returns: 'State

The state object after the folding function is applied to each element of the sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.foldBack2 folder source1 source2 state

Full Usage: Seq.foldBack2 folder source1 source2 state

Parameters:
    folder : 'T1 -> 'T2 -> 'State -> 'State - The function to update the state given the input elements.
    source1 : seq<'T1> - The first input sequence.
    source2 : seq<'T2> - The second input sequence.
    state : 'State - The initial state.

Returns: 'State The final state value.

Applies a function to corresponding elements of two collections, starting from the end of the shorter collection, threading an accumulator argument through the computation. The two sequences need not have equal lengths. If the input function is f and the elements are i0...iN and j0...jM, N < M then computes f i0 j0 (... (f iN jN s)...).

folder : 'T1 -> 'T2 -> 'State -> 'State

The function to update the state given the input elements.

source1 : seq<'T1>

The first input sequence.

source2 : seq<'T2>

The second input sequence.

state : 'State

The initial state.

Returns: 'State

The final state value.

ArgumentNullException Thrown when the either of the input sequences is null.

Seq.forall predicate source

Full Usage: Seq.forall predicate source

Parameters:
    predicate : 'T -> bool - A function to test an element of the input sequence.
    source : seq<'T> - The input sequence.

Returns: bool True if every element of the sequence satisfies the predicate; false otherwise.

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

The predicate is applied to the elements of the input sequence. If any application returns false then the overall result is false and no further elements are tested. Otherwise, true is returned.

predicate : 'T -> bool

A function to test an element of the input sequence.

source : seq<'T>

The input sequence.

Returns: bool

True if every element of the sequence satisfies the predicate; false otherwise.

ArgumentNullException Thrown when the input sequence is null.

Seq.forall2 predicate source1 source2

Full Usage: Seq.forall2 predicate source1 source2

Parameters:
    predicate : 'T1 -> 'T2 -> bool - A function to test pairs of elements from the input sequences.
    source1 : seq<'T1> - The first input sequence.
    source2 : seq<'T2> - The second input sequence.

Returns: bool True if all pairs satisfy the predicate; false otherwise.

Tests the all pairs of elements drawn from the two sequences satisfy the given predicate. If one sequence is shorter than the other then the remaining elements of the longer sequence are ignored.

predicate : 'T1 -> 'T2 -> bool

A function to test pairs of elements from the input sequences.

source1 : seq<'T1>

The first input sequence.

source2 : seq<'T2>

The second input sequence.

Returns: bool

True if all pairs satisfy the predicate; false otherwise.

ArgumentNullException Thrown when either of the input sequences is null.

Seq.groupBy projection source

Full Usage: Seq.groupBy projection source

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

Returns: seq<'Key * seq<'T>> The result sequence.

Applies a key-generating function to each element of a sequence and yields a sequence of unique keys. Each unique key contains a sequence of all elements that match to this key.

This function returns a sequence that digests the whole initial sequence as soon as that sequence is iterated. As a result this function should not be used with large or infinite sequences. The function makes no assumption on the ordering of the original sequence.

projection : 'T -> 'Key

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

source : seq<'T>

The input sequence.

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

The result sequence.

Seq.head source

Full Usage: Seq.head source

Parameters:
    source : seq<'T> - The input sequence.

Returns: 'T The first element of the sequence.

Returns the first element of the sequence.

source : seq<'T>

The input sequence.

Returns: 'T

The first element of the sequence.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input does not have any elements.

Seq.indexed source

Full Usage: Seq.indexed source

Parameters:
    source : seq<'T> - The input sequence.

Returns: seq<int * 'T> The result sequence.

Builds a new collection whose elements are the corresponding elements of the input collection paired with the integer index (from 0) of each element.

source : seq<'T>

The input sequence.

Returns: seq<int * 'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.init count initializer

Full Usage: Seq.init count initializer

Parameters:
    count : int - The maximum number of items to generate for the sequence.
    initializer : int -> 'T - A function that generates an item in the sequence from a given index.

Returns: seq<'T> The result sequence.

Generates a new sequence which, when iterated, will return successive elements by calling the given function, up to the given count. Each element is saved after its initialization. The function is passed the index of the item being generated.

The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently.

count : int

The maximum number of items to generate for the sequence.

initializer : int -> 'T

A function that generates an item in the sequence from a given index.

Returns: seq<'T>

The result sequence.

ArgumentException Thrown when count is negative.

Seq.initInfinite initializer

Full Usage: Seq.initInfinite initializer

Parameters:
    initializer : int -> 'T - A function that generates an item in the sequence from a given index.

Returns: seq<'T> The result sequence.

Generates a new sequence which, when iterated, will return successive elements by calling the given function. The results of calling the function will not be saved, that is the function will be reapplied as necessary to regenerate the elements. The function is passed the index of the item being generated.

The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently. Iteration can continue up to Int32.MaxValue.

initializer : int -> 'T

A function that generates an item in the sequence from a given index.

Returns: seq<'T>

The result sequence.

Seq.isEmpty source

Full Usage: Seq.isEmpty source

Parameters:
    source : seq<'T> - The input sequence.

Returns: bool True if the sequence is empty; false otherwise.

Returns true if the sequence contains no elements, false otherwise.

source : seq<'T>

The input sequence.

Returns: bool

True if the sequence is empty; false otherwise.

ArgumentNullException Thrown when the input sequence is null.

Seq.item index source

Full Usage: Seq.item index source

Parameters:
    index : int - The index of the element to retrieve.
    source : seq<'T> - The input sequence.

Returns: 'T The element at the specified index of the sequence.

Computes the element at the specified index in the collection.

index : int

The index of the element to retrieve.

source : seq<'T>

The input sequence.

Returns: 'T

The element at the specified index of the sequence.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the index is negative or the input sequence does not contain enough elements.

Seq.iter action source

Full Usage: Seq.iter action source

Parameters:
    action : 'T -> unit - A function to apply to each element of the sequence.
    source : seq<'T> - The input sequence.

Applies the given function to each element of the collection.

action : 'T -> unit

A function to apply to each element of the sequence.

source : seq<'T>

The input sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.iter2 action source1 source2

Full Usage: Seq.iter2 action source1 source2

Parameters:
    action : 'T1 -> 'T2 -> unit - A function to apply to each pair of elements from the input sequences.
    source1 : seq<'T1> - The first input sequence.
    source2 : seq<'T2> - The second input sequence.

Applies the given function to two collections simultaneously. If one sequence is shorter than the other then the remaining elements of the longer sequence are ignored.

action : 'T1 -> 'T2 -> unit

A function to apply to each pair of elements from the input sequences.

source1 : seq<'T1>

The first input sequence.

source2 : seq<'T2>

The second input sequence.

ArgumentNullException Thrown when either of the input sequences is null.

Seq.iteri action source

Full Usage: Seq.iteri action source

Parameters:
    action : int -> 'T -> unit - A function to apply to each element of the sequence that can also access the current index.
    source : seq<'T> - The input sequence.

Applies the given function to each element of the collection. The integer passed to the function indicates the index of element.

action : int -> 'T -> unit

A function to apply to each element of the sequence that can also access the current index.

source : seq<'T>

The input sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.iteri2 action source1 source2

Full Usage: Seq.iteri2 action source1 source2

Parameters:
    action : int -> 'T1 -> 'T2 -> unit - A function to apply to each pair of elements from the input sequences along with their index.
    source1 : seq<'T1> - The first input sequence.
    source2 : seq<'T2> - The second input sequence.

Applies the given function to two collections simultaneously. If one sequence is shorter than the other then the remaining elements of the longer sequence are ignored. The integer passed to the function indicates the index of element.

action : int -> 'T1 -> 'T2 -> unit

A function to apply to each pair of elements from the input sequences along with their index.

source1 : seq<'T1>

The first input sequence.

source2 : seq<'T2>

The second input sequence.

ArgumentNullException Thrown when either of the input sequences is null.

Seq.last source

Full Usage: Seq.last source

Parameters:
    source : seq<'T> - The input sequence.

Returns: 'T The last element of the sequence.

Returns the last element of the sequence.

source : seq<'T>

The input sequence.

Returns: 'T

The last element of the sequence.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input does not have any elements.

Seq.length source

Full Usage: Seq.length source

Parameters:
    source : seq<'T> - The input sequence.

Returns: int The length of the sequence.

Returns the length of the sequence

source : seq<'T>

The input sequence.

Returns: int

The length of the sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.map mapping source

Full Usage: Seq.map mapping source

Parameters:
    mapping : 'T -> 'U - A function to transform items from the input sequence.
    source : seq<'T> - The input sequence.

Returns: seq<'U> The result sequence.

Builds a new collection whose elements are the results of applying the given function to each of the elements of the collection. The given function will be applied as elements are demanded using the MoveNext method on enumerators retrieved from the object.

The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently.

mapping : 'T -> 'U

A function to transform items from the input sequence.

source : seq<'T>

The input sequence.

Returns: seq<'U>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.map2 mapping source1 source2

Full Usage: Seq.map2 mapping source1 source2

Parameters:
    mapping : 'T1 -> 'T2 -> 'U - A function to transform pairs of items from the input sequences.
    source1 : seq<'T1> - The first input sequence.
    source2 : seq<'T2> - The second input sequence.

Returns: seq<'U> The result sequence.

Builds a new collection whose elements are the results of applying the given function to the corresponding pairs of elements from the two sequences. If one input sequence is shorter than the other then the remaining elements of the longer sequence are ignored.

mapping : 'T1 -> 'T2 -> 'U

A function to transform pairs of items from the input sequences.

source1 : seq<'T1>

The first input sequence.

source2 : seq<'T2>

The second input sequence.

Returns: seq<'U>

The result sequence.

ArgumentNullException Thrown when either of the input sequences is null.

Seq.map3 mapping source1 source2 source3

Full Usage: Seq.map3 mapping source1 source2 source3

Parameters:
    mapping : 'T1 -> 'T2 -> 'T3 -> 'U - The function to transform triples of elements from the input sequences.
    source1 : seq<'T1> - The first input sequence.
    source2 : seq<'T2> - The second input sequence.
    source3 : seq<'T3> - The third input sequence.

Returns: seq<'U> The result sequence.

Builds a new collection whose elements are the results of applying the given function to the corresponding triples of elements from the three sequences. If one input sequence if shorter than the others then the remaining elements of the longer sequences are ignored.

mapping : 'T1 -> 'T2 -> 'T3 -> 'U

The function to transform triples of elements from the input sequences.

source1 : seq<'T1>

The first input sequence.

source2 : seq<'T2>

The second input sequence.

source3 : seq<'T3>

The third input sequence.

Returns: seq<'U>

The result sequence.

ArgumentNullException Thrown when any of the input sequences is null.

Seq.mapFold mapping state source

Full Usage: Seq.mapFold mapping state source

Parameters:
    mapping : 'State -> 'T -> 'Result * 'State - The function to transform elements from the input collection and accumulate the final value.
    state : 'State - The initial state.
    source : seq<'T> - The input collection.

Returns: seq<'Result> * 'State The collection of transformed elements, and the final accumulated value.

Combines map and fold. Builds a new collection whose elements are the results of applying the given function to each of the elements of the collection. The function is also used to accumulate a final value.

This function digests the whole initial sequence as soon as it is called. As a result this function should not be used with large or infinite sequences.

mapping : 'State -> 'T -> 'Result * 'State

The function to transform elements from the input collection and accumulate the final value.

state : 'State

The initial state.

source : seq<'T>

The input collection.

Returns: seq<'Result> * 'State

The collection of transformed elements, and the final accumulated value.

ArgumentNullException Thrown when the input collection is null.

Seq.mapFoldBack mapping source state

Full Usage: Seq.mapFoldBack mapping source state

Parameters:
    mapping : 'T -> 'State -> 'Result * 'State - The function to transform elements from the input collection and accumulate the final value.
    source : seq<'T> - The input collection.
    state : 'State - The initial state.

Returns: seq<'Result> * 'State The collection of transformed elements, and the final accumulated value.

Combines map and foldBack. Builds a new collection whose elements are the results of applying the given function to each of the elements of the collection. The function is also used to accumulate a final value.

This function digests the whole initial sequence as soon as it is called. As a result this function should not be used with large or infinite sequences.

mapping : 'T -> 'State -> 'Result * 'State

The function to transform elements from the input collection and accumulate the final value.

source : seq<'T>

The input collection.

state : 'State

The initial state.

Returns: seq<'Result> * 'State

The collection of transformed elements, and the final accumulated value.

ArgumentNullException Thrown when the input collection is null.

Seq.mapi mapping source

Full Usage: Seq.mapi mapping source

Parameters:
    mapping : int -> 'T -> 'U - A function to transform items from the input sequence that also supplies the current index.
    source : seq<'T> - The input sequence.

Returns: seq<'U> The result sequence.

Builds a new collection whose elements are the results of applying the given function to each of the elements of the collection. The integer index passed to the function indicates the index (from 0) of element being transformed.

mapping : int -> 'T -> 'U

A function to transform items from the input sequence that also supplies the current index.

source : seq<'T>

The input sequence.

Returns: seq<'U>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.mapi2 mapping source1 source2

Full Usage: Seq.mapi2 mapping source1 source2

Parameters:
    mapping : int -> 'T1 -> 'T2 -> 'U - A function to transform pairs of items from the input sequences that also supplies the current index.
    source1 : seq<'T1> - The first input sequence.
    source2 : seq<'T2> - The second input sequence.

Returns: seq<'U> The result sequence.

Builds a new collection whose elements are the results of applying the given function to the corresponding pairs of elements from the two sequences. If one input sequence is shorter than the other then the remaining elements of the longer sequence are ignored. The integer index passed to the function indicates the index (from 0) of element being transformed.

mapping : int -> 'T1 -> 'T2 -> 'U

A function to transform pairs of items from the input sequences that also supplies the current index.

source1 : seq<'T1>

The first input sequence.

source2 : seq<'T2>

The second input sequence.

Returns: seq<'U>

The result sequence.

ArgumentNullException Thrown when either of the input sequences is null.

Seq.max source

Full Usage: Seq.max source

Parameters:
    source : seq<'T> - The input sequence.

Returns: 'T The largest element of the sequence.

Returns the greatest of all elements of the sequence, compared via Operators.max

source : seq<'T>

The input sequence.

Returns: 'T

The largest element of the sequence.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input sequence is empty.

Seq.maxBy projection source

Full Usage: Seq.maxBy projection source

Parameters:
    projection : 'T -> 'U - A function to transform items from the input sequence into comparable keys.
    source : seq<'T> - The input sequence.

Returns: 'T The largest element of the sequence.

Returns the greatest of all elements of the sequence, compared via Operators.max on the function result.

projection : 'T -> 'U

A function to transform items from the input sequence into comparable keys.

source : seq<'T>

The input sequence.

Returns: 'T

The largest element of the sequence.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input sequence is empty.

Seq.min source

Full Usage: Seq.min source

Parameters:
    source : seq<'T> - The input sequence.

Returns: 'T The smallest element of the sequence.

Returns the lowest of all elements of the sequence, compared via Operators.min.

source : seq<'T>

The input sequence.

Returns: 'T

The smallest element of the sequence.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input sequence is empty.

Seq.minBy projection source

Full Usage: Seq.minBy projection source

Parameters:
    projection : 'T -> 'U - A function to transform items from the input sequence into comparable keys.
    source : seq<'T> - The input sequence.

Returns: 'T The smallest element of the sequence.

Returns the lowest of all elements of the sequence, compared via Operators.min on the function result.

projection : 'T -> 'U

A function to transform items from the input sequence into comparable keys.

source : seq<'T>

The input sequence.

Returns: 'T

The smallest element of the sequence.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input sequence is empty.

Seq.ofArray source

Full Usage: Seq.ofArray source

Parameters:
    source : 'T[] - The input array.

Returns: seq<'T> The result sequence.

Views the given array as a sequence.

source : 'T[]

The input array.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.ofList source

Full Usage: Seq.ofList source

Parameters:
    source : 'T list - The input list.

Returns: seq<'T> The result sequence.

Views the given list as a sequence.

source : 'T list

The input list.

Returns: seq<'T>

The result sequence.

Seq.pairwise source

Full Usage: Seq.pairwise source

Parameters:
    source : seq<'T> - The input sequence.

Returns: seq<'T * 'T> The result sequence.

Returns a sequence of each element in the input sequence and its predecessor, with the exception of the first element which is only returned as the predecessor of the second element.

source : seq<'T>

The input sequence.

Returns: seq<'T * 'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.permute indexMap source

Full Usage: Seq.permute indexMap source

Parameters:
    indexMap : int -> int - The function that maps input indices to output indices.
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Returns a sequence with all elements permuted according to the specified permutation.

This function consumes the whole input sequence before yielding the first element of the result sequence.

indexMap : int -> int

The function that maps input indices to output indices.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when indexMap does not produce a valid permutation.

Seq.pick chooser source

Full Usage: Seq.pick chooser source

Parameters:
    chooser : 'T -> 'U option - A function to transform each item of the input sequence into an option of the output type.
    source : seq<'T> - The input sequence.

Returns: 'U The selected element.

Applies the given function to successive elements, returning the first x where the function returns "Some(x)".

chooser : 'T -> 'U option

A function to transform each item of the input sequence into an option of the output type.

source : seq<'T>

The input sequence.

Returns: 'U

The selected element.

ArgumentNullException Thrown when the input sequence is null.
KeyNotFoundException Thrown when every item of the sequence evaluates to None when the given function is applied.

Seq.readonly source

Full Usage: Seq.readonly source

Parameters:
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Builds a new sequence object that delegates to the given sequence object. This ensures the original sequence cannot be rediscovered and mutated by a type cast. For example, if given an array the returned sequence will return the elements of the array, but you cannot cast the returned sequence object to an array.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.reduce reduction source

Full Usage: Seq.reduce reduction source

Parameters:
    reduction : 'T -> 'T -> 'T - A function that takes in the current accumulated result and the next element of the sequence to produce the next accumulated result.
    source : seq<'T> - The input sequence.

Returns: 'T The final result of the reduction function.

Applies a function to each element of the sequence, threading an accumulator argument through the computation. Begin by applying the function to the first two elements. Then feed this result into the function along with the third element and so on. Return the final result.

reduction : 'T -> 'T -> 'T

A function that takes in the current accumulated result and the next element of the sequence to produce the next accumulated result.

source : seq<'T>

The input sequence.

Returns: 'T

The final result of the reduction function.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input sequence is empty.

Seq.reduceBack reduction source

Full Usage: Seq.reduceBack reduction source

Parameters:
    reduction : 'T -> 'T -> 'T - A function that takes in the next-to-last element of the sequence and the current accumulated result to produce the next accumulated result.
    source : seq<'T> - The input sequence.

Returns: 'T The final result of the reductions.

Applies a function to each element of the sequence, 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-1 iN)).

This function consumes the whole input sequence before returning the result.

reduction : 'T -> 'T -> 'T

A function that takes in the next-to-last element of the sequence and the current accumulated result to produce the next accumulated result.

source : seq<'T>

The input sequence.

Returns: 'T

The final result of the reductions.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input sequence is empty.

Seq.replicate count initial

Full Usage: Seq.replicate count initial

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

Returns: seq<'T> The generated sequence.

Creates a sequence by replicating the given initial value.

count : int

The number of elements to replicate.

initial : 'T

The value to replicate

Returns: seq<'T>

The generated sequence.

Seq.rev source

Full Usage: Seq.rev source

Parameters:
    source : seq<'T> - The input sequence.

Returns: seq<'T> The reversed sequence.

Returns a new sequence with the elements in reverse order.

This function consumes the whole input sequence before yielding the first element of the reversed sequence.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The reversed sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.scan folder state source

Full Usage: Seq.scan folder state source

Parameters:
    folder : 'State -> 'T -> 'State - A function that updates the state with each element from the sequence.
    state : 'State - The initial state.
    source : seq<'T> - The input sequence.

Returns: seq<'State> The resulting sequence of computed states.

Like fold, but computes on-demand and returns the sequence of intermediary and final results.

folder : 'State -> 'T -> 'State

A function that updates the state with each element from the sequence.

state : 'State

The initial state.

source : seq<'T>

The input sequence.

Returns: seq<'State>

The resulting sequence of computed states.

ArgumentNullException Thrown when the input sequence is null.

Seq.scanBack folder source state

Full Usage: Seq.scanBack folder source state

Parameters:
    folder : 'T -> 'State -> 'State - A function that updates the state with each element from the sequence.
    source : seq<'T> - The input sequence.
    state : 'State - The initial state.

Returns: seq<'State> The resulting sequence of computed states.

Like foldBack, but returns the sequence of intermediary and final results.

This function returns a sequence that digests the whole initial sequence as soon as that sequence is iterated. As a result this function should not be used with large or infinite sequences.

folder : 'T -> 'State -> 'State

A function that updates the state with each element from the sequence.

source : seq<'T>

The input sequence.

state : 'State

The initial state.

Returns: seq<'State>

The resulting sequence of computed states.

ArgumentNullException Thrown when the input sequence is null.

Seq.singleton value

Full Usage: Seq.singleton value

Parameters:
    value : 'T - The input item.

Returns: seq<'T> The result sequence of one item.

Returns a sequence that yields one item only.

value : 'T

The input item.

Returns: seq<'T>

The result sequence of one item.

Seq.skip count source

Full Usage: Seq.skip count source

Parameters:
    count : int - The number of items to skip.
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Returns a sequence that skips N elements of the underlying sequence and then yields the remaining elements of the sequence.

count : int

The number of items to skip.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.
InvalidOperationException Thrown when count exceeds the number of elements in the sequence.

Seq.skipWhile predicate source

Full Usage: Seq.skipWhile predicate source

Parameters:
    predicate : 'T -> bool - A function that evaluates an element of the sequence to a boolean value.
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Returns a sequence that, when iterated, skips elements of the underlying sequence while the given predicate returns True, and then yields the remaining elements of the sequence.

predicate : 'T -> bool

A function that evaluates an element of the sequence to a boolean value.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.sort source

Full Usage: Seq.sort source

Parameters:
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Yields a sequence ordered by keys.

This function returns a sequence that digests the whole initial sequence as soon as that sequence is iterated. As a result this function should not be used with large or infinite sequences. The function makes no assumption on the ordering of the original sequence and uses a stable sort, that is the original order of equal elements is preserved.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.sortBy projection source

Full Usage: Seq.sortBy projection source

Parameters:
    projection : 'T -> 'Key - A function to transform items of the input sequence into comparable keys.
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Applies a key-generating function to each element of a sequence and yield a sequence ordered by keys. The keys are compared using generic comparison as implemented by Operators.compare.

This function returns a sequence that digests the whole initial sequence as soon as that sequence is iterated. As a result this function should not be used with large or infinite sequences. The function makes no assumption on the ordering of the original sequence and uses a stable sort, that is the original order of equal elements is preserved.

projection : 'T -> 'Key

A function to transform items of the input sequence into comparable keys.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.sortByDescending projection source

Full Usage: Seq.sortByDescending projection source

Parameters:
    projection : 'T -> 'Key - A function to transform items of the input sequence into comparable keys.
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Applies a key-generating function to each element of a sequence and yield a sequence ordered descending by keys. The keys are compared using generic comparison as implemented by Operators.compare.

This function returns a sequence that digests the whole initial sequence as soon as that sequence is iterated. As a result this function should not be used with large or infinite sequences. The function makes no assumption on the ordering of the original sequence. This is a stable sort, that is the original order of equal elements is preserved.

projection : 'T -> 'Key

A function to transform items of the input sequence into comparable keys.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.sortDescending source

Full Usage: Seq.sortDescending source

Parameters:
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Yields a sequence ordered descending by keys.

This function returns a sequence that digests the whole initial sequence as soon as that sequence is iterated. As a result this function should not be used with large or infinite sequences. The function makes no assumption on the ordering of the original sequence. This is a stable sort, that is the original order of equal elements is preserved.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.sortWith comparer source

Full Usage: Seq.sortWith comparer source

Parameters:
    comparer : 'T -> 'T -> int - The function to compare the collection elements.
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Yields a sequence ordered using the given comparison function.

This function returns a sequence that digests the whole initial sequence as soon as that sequence is iterated. As a result this function should not be used with large or infinite sequences. The function makes no assumption on the ordering of the original sequence and uses a stable sort, that is the original order of equal elements is preserved.

comparer : 'T -> 'T -> int

The function to compare the collection elements.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

Seq.splitInto count source

Full Usage: Seq.splitInto count source

Parameters:
    count : int - The maximum number of chunks.
    source : seq<'T> - The input sequence.

Returns: seq<'T[]> The sequence split into chunks.

Splits the input sequence into at most count chunks.

This function returns a sequence that digests the whole initial sequence as soon as that sequence is iterated. As a result this function should not be used with large or infinite sequences.This function consumes the whole input sequence before yielding the first element of the result sequence.

count : int

The maximum number of chunks.

source : seq<'T>

The input sequence.

Returns: seq<'T[]>

The sequence split into chunks.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when count is not positive.

Seq.sum source

Full Usage: Seq.sum source

Parameters:
    source : seq<^T> - The input sequence.

Returns: ^T The computed sum.

Returns the sum of the elements in the sequence.

The elements are summed using the + operator and Zero property associated with the generated type.

source : seq<^T>

The input sequence.

Returns: ^T

The computed sum.

Seq.sumBy projection source

Full Usage: Seq.sumBy projection source

Parameters:
    projection : 'T -> ^U - A function to transform items from the input sequence into the type that will be summed.
    source : seq<'T> - The input sequence.

Returns: ^U The computed sum.

Returns the sum of the results generated by applying the function to each element of the sequence.

The generated elements are summed using the + operator and Zero property associated with the generated type.

projection : 'T -> ^U

A function to transform items from the input sequence into the type that will be summed.

source : seq<'T>

The input sequence.

Returns: ^U

The computed sum.

Seq.tail source

Full Usage: Seq.tail source

Parameters:
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Returns a sequence that skips 1 element of the underlying sequence and then yields the remaining elements of the sequence.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.
InvalidOperationException Thrown when the input sequence is empty.

Seq.take count source

Full Usage: Seq.take count source

Parameters:
    count : int - The number of items to take.
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Returns the first N elements of the sequence.

Throws InvalidOperationException if the count exceeds the number of elements in the sequence. Seq.truncate returns as many items as the sequence contains instead of throwing an exception.

count : int

The number of items to take.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input sequence is empty.
InvalidOperationException Thrown when count exceeds the number of elements in the sequence.

Seq.takeWhile predicate source

Full Usage: Seq.takeWhile predicate source

Parameters:
    predicate : 'T -> bool - A function that evaluates to false when no more items should be returned.
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Returns a sequence that, when iterated, yields elements of the underlying sequence while the given predicate returns True, and then returns no further elements.

predicate : 'T -> bool

A function that evaluates to false when no more items should be returned.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.toArray source

Full Usage: Seq.toArray source

Parameters:
    source : seq<'T> - The input sequence.

Returns: 'T[] The result array.

Builds an array from the given collection.

source : seq<'T>

The input sequence.

Returns: 'T[]

The result array.

ArgumentNullException Thrown when the input sequence is null.

Seq.toList source

Full Usage: Seq.toList source

Parameters:
    source : seq<'T> - The input sequence.

Returns: 'T list The result list.

Builds a list from the given collection.

source : seq<'T>

The input sequence.

Returns: 'T list

The result list.

ArgumentNullException Thrown when the input sequence is null.

Seq.transpose source

Full Usage: Seq.transpose source

Parameters:
    source : seq<'Collection> - The input sequence.

Returns: seq<seq<'T>> The transposed sequence.

Returns the transpose of the given sequence of sequences.

This function returns a sequence that digests the whole initial sequence as soon as that sequence is iterated. As a result this function should not be used with large or infinite sequences.

source : seq<'Collection>

The input sequence.

Returns: seq<seq<'T>>

The transposed sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.truncate count source

Full Usage: Seq.truncate count source

Parameters:
    count : int - The maximum number of items to enumerate.
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Returns a sequence that when enumerated returns at most N elements.

count : int

The maximum number of items to enumerate.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.tryExactlyOne source

Full Usage: Seq.tryExactlyOne source

Parameters:
    source : seq<'T> - The input sequence.

Returns: 'T option The only element of the sequence or None.

Returns the only element of the sequence or None if sequence is empty or contains more than one element.

source : seq<'T>

The input sequence.

Returns: 'T option

The only element of the sequence or None.

ArgumentNullException Thrown when the input sequence is null.

Seq.tryFind predicate source

Full Usage: Seq.tryFind predicate source

Parameters:
    predicate : 'T -> bool - A function that evaluates to a Boolean when given an item in the sequence.
    source : seq<'T> - The input sequence.

Returns: 'T option The found element or None.

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

predicate : 'T -> bool

A function that evaluates to a Boolean when given an item in the sequence.

source : seq<'T>

The input sequence.

Returns: 'T option

The found element or None.

ArgumentNullException Thrown when the input sequence is null.

Seq.tryFindBack predicate source

Full Usage: Seq.tryFindBack predicate source

Parameters:
    predicate : 'T -> bool - A function that evaluates to a Boolean when given an item in the sequence.
    source : seq<'T> - The input sequence.

Returns: 'T option The found element or None.

Returns the last element for which the given function returns True. Return None if no such element exists.

This function digests the whole initial sequence as soon as it is called. As a result this function should not be used with large or infinite sequences.

predicate : 'T -> bool

A function that evaluates to a Boolean when given an item in the sequence.

source : seq<'T>

The input sequence.

Returns: 'T option

The found element or None.

ArgumentNullException Thrown when the input sequence is null.

Seq.tryFindIndex predicate source

Full Usage: Seq.tryFindIndex predicate source

Parameters:
    predicate : 'T -> bool - A function that evaluates to a Boolean when given an item in the sequence.
    source : seq<'T> - The input sequence.

Returns: int option The found index or None.

Returns the index of the first element in the sequence that satisfies the given predicate. Return None if no such element exists.

predicate : 'T -> bool

A function that evaluates to a Boolean when given an item in the sequence.

source : seq<'T>

The input sequence.

Returns: int option

The found index or None.

ArgumentNullException Thrown when the input sequence is null.

Seq.tryFindIndexBack predicate source

Full Usage: Seq.tryFindIndexBack predicate source

Parameters:
    predicate : 'T -> bool - A function that evaluates to a Boolean when given an item in the sequence.
    source : seq<'T> - The input sequence.

Returns: int option The found index or None.

Returns the index of the last element in the sequence that satisfies the given predicate. Return None if no such element exists.

This function digests the whole initial sequence as soon as it is called. As a result this function should not be used with large or infinite sequences.

predicate : 'T -> bool

A function that evaluates to a Boolean when given an item in the sequence.

source : seq<'T>

The input sequence.

Returns: int option

The found index or None.

ArgumentNullException Thrown when the input sequence is null.

Seq.tryHead source

Full Usage: Seq.tryHead source

Parameters:
    source : seq<'T> - The input sequence.

Returns: 'T option The first element of the sequence or None.

Returns the first element of the sequence, or None if the sequence is empty.

source : seq<'T>

The input sequence.

Returns: 'T option

The first element of the sequence or None.

ArgumentNullException Thrown when the input sequence is null.

Seq.tryItem index source

Full Usage: Seq.tryItem index source

Parameters:
    index : int - The index of element to retrieve.
    source : seq<'T> - The input sequence.

Returns: 'T option The nth element of the sequence or None.

Tries to find the nth element in the sequence. Returns None if index is negative or the input sequence does not contain enough elements.

index : int

The index of element to retrieve.

source : seq<'T>

The input sequence.

Returns: 'T option

The nth element of the sequence or None.

ArgumentNullException Thrown when the input sequence is null.

Seq.tryLast source

Full Usage: Seq.tryLast source

Parameters:
    source : seq<'T> - The input sequence.

Returns: 'T option The last element of the sequence or None.

Returns the last element of the sequence. Return None if no such element exists.

source : seq<'T>

The input sequence.

Returns: 'T option

The last element of the sequence or None.

ArgumentNullException Thrown when the input sequence is null.

Seq.tryPick chooser source

Full Usage: Seq.tryPick chooser source

Parameters:
    chooser : 'T -> 'U option - A function that transforms items from the input sequence into options.
    source : seq<'T> - The input sequence.

Returns: 'U option The chosen element or None.

Applies the given function to successive elements, returning the first result where the function returns "Some(x)".

chooser : 'T -> 'U option

A function that transforms items from the input sequence into options.

source : seq<'T>

The input sequence.

Returns: 'U option

The chosen element or None.

ArgumentNullException Thrown when the input sequence is null.

Seq.unfold generator state

Full Usage: Seq.unfold generator state

Parameters:
    generator : 'State -> ('T * 'State) option - A function that takes in the current state and returns an option tuple of the next element of the sequence and the next state value.
    state : 'State - The initial state value.

Returns: seq<'T> The result sequence.

Returns a sequence that contains the elements generated by the given computation. The given initial state argument is passed to the element generator. For each IEnumerator elements in the stream are generated on-demand by applying the element generator, until a None value is returned by the element generator. Each call to the element generator returns a new residual state.

The stream will be recomputed each time an IEnumerator is requested and iterated for the Seq.

generator : 'State -> ('T * 'State) option

A function that takes in the current state and returns an option tuple of the next element of the sequence and the next state value.

state : 'State

The initial state value.

Returns: seq<'T>

The result sequence.

Seq.where predicate source

Full Usage: Seq.where predicate source

Parameters:
    predicate : 'T -> bool - A function to test whether each item in the input sequence should be included in the output.
    source : seq<'T> - The input sequence.

Returns: seq<'T> The result sequence.

Returns a new collection containing only the elements of the collection for which the given predicate returns "true".

The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently. Remember sequence is lazy, effects are delayed until it is enumerated. A synonym for Seq.filter.

predicate : 'T -> bool

A function to test whether each item in the input sequence should be included in the output.

source : seq<'T>

The input sequence.

Returns: seq<'T>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.

Seq.windowed windowSize source

Full Usage: Seq.windowed windowSize source

Parameters:
    windowSize : int - The number of elements in each window.
    source : seq<'T> - The input sequence.

Returns: seq<'T[]> The result sequence.

Returns a sequence that yields sliding windows containing elements drawn from the input sequence. Each window is returned as a fresh array.

windowSize : int

The number of elements in each window.

source : seq<'T>

The input sequence.

Returns: seq<'T[]>

The result sequence.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when windowSize is not positive.

Seq.zip source1 source2

Full Usage: Seq.zip source1 source2

Parameters:
    source1 : seq<'T1> - The first input sequence.
    source2 : seq<'T2> - The second input sequence.

Returns: seq<'T1 * 'T2> The result sequence.

Combines the two sequences into a list of pairs. The two sequences need not have equal lengths: when one sequence is exhausted any remaining elements in the other sequence are ignored.

source1 : seq<'T1>

The first input sequence.

source2 : seq<'T2>

The second input sequence.

Returns: seq<'T1 * 'T2>

The result sequence.

ArgumentNullException Thrown when either of the input sequences is null.

Seq.zip3 source1 source2 source3

Full Usage: Seq.zip3 source1 source2 source3

Parameters:
    source1 : seq<'T1> - The first input sequence.
    source2 : seq<'T2> - The second input sequence.
    source3 : seq<'T3> - The third input sequence.

Returns: seq<'T1 * 'T2 * 'T3> The result sequence.

Combines the three sequences into a list of triples. The sequences need not have equal lengths: when one sequence is exhausted any remaining elements in the other sequences are ignored.

source1 : seq<'T1>

The first input sequence.

source2 : seq<'T2>

The second input sequence.

source3 : seq<'T3>

The third input sequence.

Returns: seq<'T1 * 'T2 * 'T3>

The result sequence.

ArgumentNullException Thrown when any of the input sequences is null.