[Home] Module Microsoft.FSharp.Collections.Seq


Basic operations on IEnumerables.

Modules (as contributed by assembly 'FSharp.Core')

ModuleDescription
Microsoft.FSharp.Collections.Seq.SequenceExpressionHelpers

Type Definitions

TypeDescription
type CachedSeq A CachedSeq is the value returned by Seq.cache. It is a sequence object that also is IDisposable.

Values

ValueDescription
val append : seq<'a> -> seq<'a> -> seq<'a>
Wrap the two 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 from multiple threads simultaneously.
val average : overloaded
Return the average of the elements in the sequence
val average_by : overloaded
Return the average of the results generated by applying the function to each element of the sequence.
val cache : seq<'a> -> CachedSeq<'a>
Return a CachedSeq for a sequence that corresponds to a cached version of the input sequence. This 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 (it's enumeration is cached). 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 from multiple threads simultaneously. Note, once enumeration of the input sequence has started, it's enumerator will be held on to by this object until the enumeration has completed. At that point, the enumerator will be disposed. The enumerator and underlying cache storage may be released by disposing or clearing the CachedSeq.
val cast : IEnumerable -> seq<'a>
Wrap 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 from multiple threads simultaneously.
val choose : ('a -> 'b option) -> seq<'a> -> seq<'b>
Apply 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 from multiple threads simultaneously. Remember sequence is lazy, effects are delayed until it is enumerated.
val compare : ('a -> 'a -> int) -> seq<'a> -> seq<'a> -> int
Compare two sequence's using the given comparison function. Both input IEnumerables are assumed to be in a canonical order (i.e. sorted)
val concat : seq<#seq<'a>> -> seq<'a>
Wrap 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 from multiple threads simultaneously.
val count_by : ('a -> 'key) -> seq<'a> -> seq<'key * int>
Apply a key-generating function to each element of a sequence and return a sequence yielding unique keys and their number of occurences 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.
val delay : (unit -> seq<'a>) -> seq<'a>
Return a sequence that is built from the given delayed specification of an Seq. The input function is evaluated each time an IEnumerator for the sequence is requested.
val distinct : seq<'a> -> seq<'a>
Return 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.
val distinct_by : ('a -> 'key) -> seq<'a> -> seq<'a>
Return 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.
[<GeneralizableValueAttribute ()>]
val empty<'a> : seq<'a>
Create an empty sequence
val exists : ('a -> bool) -> seq<'a> -> bool
Test if any element of the collection satisfies the given predicate. If the elements are i0...iN then computes "p i0 or ... or p iN".
val exists2 : ('a -> 'b -> bool) -> seq<'a> -> seq<'b> -> bool
Test the any pair of elements drawn from the two sequences satisfies the given predicate. If one sequence is shorter than the other than the remaining elements of the longer sequence are ignored
val filter : ('a -> bool) -> seq<'a> -> seq<'a>
Return 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 from multiple threads simultaneously. Remember sequence is lazy, effects are delayed until it is enumerated.
val find : ('a -> bool) -> seq<'a> -> 'a
Return the first element for which the given function returns true. Raise KeyNotFoundException if no such element exists.
val find_index : ('v -> bool) -> seq<'k * 'v> -> 'k
Return the index of the first element in the sequence of pairs that satisfies the given predicate. Raise KeyNotFoundException if no such element exists.
val find_indexi : ('k -> 'v -> bool) -> seq<'k * 'v> -> 'k
Return the index of the first element in the sequence of pairs that satisfies the given predicate. Raise KeyNotFoundException if no such element exists.
val first : ('a -> 'b option) -> seq<'a> -> 'b option
Apply the given function to successive elements, returning the first result where function returns "Some(x)" for some x.
val fold : ('b -> 'a -> 'b) -> 'b -> seq<'a> -> 'b
Apply a function to each element of the collection, threading an accumulator argument through the computation. If the elements are i0...iN then computes f (... (f s i0)...) iN
val for_all : ('a -> bool) -> seq<'a> -> bool
Test if all elements of the collection satisfy the given predicate. If the elements are i0...iN then computes "p i0 && ... && p iN".
val for_all2 : ('a -> 'b -> bool) -> seq<'a> -> seq<'b> -> bool
Test the all pairs of elements drawn from the two sequences satisfies the given predicate. If one sequence is shorter than the other than the remaining elements of the longer sequence are ignored
val group_by : ('a -> 'key) -> seq<'a> -> seq<'key * seq<'a>>
Apply a key-generating function to each element of a sequence and yields a sequence of unique keys. Each unique key has also contains a sequence of all elements that match to this key. 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.
val hd : seq<'a> -> 'a
Return the first element of the sequence.
val init_finite : int -> (int -> 'a) -> seq<'a>
Generate a new sequence which, when iterated, will return successive elements by calling the given function, up to the given count. The results of calling the function will not be saved, i.e. 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 from multiple threads simultaneously.
val init_infinite : (int -> 'a) -> seq<'a>
Generate 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, i.e. 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 from multiple threads simultaneously.
val is_empty : seq<'a> -> bool
Return true if the sequence contains no elements, false otherwise
val iter : ('a -> unit) -> seq<'a> -> unit
Apply the given function to each element of the collection.
val iter2 : ('a -> 'b -> unit) -> seq<'a> -> seq<'b> -> unit
Apply the given function to two collections simultaneously. If one sequence is shorter than the other than the remaining elements of the longer sequence are ignored.
val iteri : (int -> 'a -> unit) -> seq<'a> -> unit
Apply the given function to each element of the collection. The integer passed to the function indicates the index of element.
val length : seq<'a> -> int
Return the length of the sequence
val map : ('a -> 'b) -> seq<'a> -> seq<'b>
Build a new collection whose elements are the results of applying the given function to each of the elements of the collection. The function will be applied as elements are demanded using the 'Current' property on iterators retrieved from the object. Generating multiple iterators or calling the 'Current' property multiple times may result in the function being called multiple times. The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed from multiple threads simultaneously. Remember sequence is lazy, effects are delayed until it is enumerated.
val map2 : ('a -> 'b -> 'c) -> seq<'a> -> seq<'b> -> seq<'c>
Build 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 than the remaining elements of the longer sequence are ignored.
val map_concat : ('a -> #seq<'b>) -> seq<'a> -> seq<'b>
For each element of the enumeration apply the given function and concatenate all the results. Remember sequence is lazy, effects are delayed until it is enumerated.
val mapi : (int -> 'a -> 'b) -> seq<'a> -> seq<'b>
Build 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.
val max : seq<'a> -> 'a
Return the greatest of all elements of the sequence, compared via Operators.max
val max_by : ('a -> 'b) -> seq<'a> -> 'a
Return the greatest of all elements of the array, compared via Operators.max on the function result
val min : seq<'a> -> 'a
Return the lowest of all elements of the sequence, compared via Operators.min
val min_by : ('a -> 'b) -> seq<'a> -> 'a
Return the lowest of all elements of the array, compared via Operators.min on the function result
val nth : int -> seq<'a> -> 'a
Compute the nth element in the collection.
val of_array : 'a array -> seq<'a>
Build a collection from the given array
val of_list : 'a list -> seq<'a>
Build a collection from the given array
val pairwise : seq<'a> -> seq<'a * 'a>
Return 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.
val readonly : seq<'a> -> seq<'a>
Build a new sequence object that delegates to the given sequence object. This ensures the original sequence can't 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 can't cast the returned sequence object to an array.
val reduce : ('a -> 'a -> 'a) -> seq<'a> -> 'a
Apply 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. Raises ArgumentException if the sequence has no elements.
val scan : ('b -> 'a -> 'b) -> 'b -> seq<'a> -> seq<'b>
Like fold, but compute on-demand and return the sequence of intermediary and final results
val scan1 : ('a -> 'a -> 'a) -> seq<'a> -> seq<'a>
Like fold1, but compute on-demand and return the sequence of intermediary and final results
val singleton : 'a -> seq<'a>
Return a sequence that yields one item only.
val skip : int -> seq<'a> -> seq<'a>
Return a sequence that skips N elements of the underlying sequence and then yields the remaining elements of the sequence
val skip_while : ('a -> bool) -> seq<'a> -> seq<'a>
Return 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
val sort : seq<'a> -> seq<'a>
Yield a sequence ordered by keys. 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.
val sort_by : ('a -> 'key) -> seq<'a> -> seq<'a>
Apply a key-generating function to each element of a sequence and yields a sequence ordered by keys. 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.
val sum : overloaded
Return the sum of the elements in the sequence
val sum_by : overloaded
Return the sum of the results generated by applying the function to each element of the sequence.
val take : int -> seq<'a> -> seq<'a>
Return the first N elements of the sequence.
val take_while : ('a -> bool) -> seq<'a> -> seq<'a>
Return a sequence that, when iterated, yields elements of the underlying sequence while the given predicate returns 'true', and returns no further elements
val to_array : seq<'a> -> 'a array
Build an array from the given collection
val to_list : seq<'a> -> 'a list
Build a list from the given collection
val truncate : int -> seq<'a> -> seq<'a>
Return a sequence that when enumerated returns at most N elements.
val tryfind : ('a -> bool) -> seq<'a> -> 'a option
Return the first element for which the given function returns true. Return None if no such element exists.
val tryfind_index : ('v -> bool) -> seq<'k * 'v> -> 'k option
Return the index of the first element in the sequence of pairs that satisfies the given predicate. Return 'None' if no such element exists.
val tryfind_indexi : ('k -> 'v -> bool) -> seq<'k * 'v> -> 'k option
Return the index of the first element in the sequence of pairs that satisfies the given predicate. Return 'None' if no such element exists.
val unfold : ('b -> ('a * 'b) option) -> 'b -> seq<'a>
Return 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'. Note the stream will be recomputed each time an IEnumerator is requested and iterated for the Seq. The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed from multiple threads simultaneously.
val windowed : int -> seq<'a> -> seq<'a []>
Return a sequence that yields 'sliding windows' of containing elements drawn from the input sequence. Each window is returned as a fresh array.
val zip : seq<'a> -> seq<'b> -> seq<'a * 'b>
Combine 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.
val zip3 :
  seq<'a> -> seq<'b> -> seq<'c> -> seq<'a * 'b * 'c>
Combine the three sequences into a list of triples. The two sequences need not have equal lengths: when one sequence is exhausted any remaining elements in the other sequence are ignored.

See Also

Microsoft.FSharp.Collections


Documentation for assembly FSharp.Core, version 1.9.6.0, generated using F# Programming Language version 1.9.6.0