SeqExtensions Module
Fluent extension operations on sequences.
Types
Type | Description |
Type extensions
Type extension | Description | ||||||
Full Usage:
this.IsEmpty
Parameters:
unit
Returns: bool
True if the sequence is empty; false otherwise.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.IsEmpty
Returns: bool
True if the sequence is empty; false otherwise.
Modifiers: inline abstract |
Extended Type:
|
||||||
Full Usage:
this[index]
Parameters:
int
-
The index of the element to retrieve.
Returns: 'T
The element at the specified index of the sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.allPairs source2
Parameters:
'a seq
-
The second input sequence.
Returns: ('T * 'a) seq
The resulting sequence of pairs.
Modifiers: inline Type parameters: 'a |
Extended Type:
|
||||||
Full Usage:
this.append source2
Parameters:
'T seq
-
The second sequence.
Returns: 'T seq
The result sequence.
Modifiers: inline |
The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently.
Extended Type:
|
||||||
Full Usage:
this.cache ()
Parameters:
unit
Returns: 'T seq
The result sequence.
Modifiers: inline |
Returns 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. 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.
Extended Type:
|
||||||
Full Usage:
this.choose chooser
Parameters:
'T -> 'U option
-
A function to transform items of type T into options of type U.
Returns: 'U seq
The result sequence.
Modifiers: inline Type parameters: 'U |
The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently.
Extended Type:
|
||||||
Full Usage:
this.chunkBySize chunkSize
Parameters:
int
-
The maximum size of each chunk.
Returns: 'T[] seq
The sequence divided into chunks.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.collect mapping
Parameters:
'T -> 'Collection
-
A function to transform elements of the input sequence into the sequences
that will then be concatenated.
Returns: 'U seq
The result sequence.
Modifiers: inline Type parameters: 'Collection, 'U |
Remember sequence is lazy, effects are delayed until it is enumerated.
Extended Type:
|
||||||
Full Usage:
this.compareWith (comparer, source2)
Parameters:
'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.
source2 : 'T seq
-
The second input sequence.
Returns: int
The first non-zero value from the comparison function.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.countBy projection
Parameters:
'T -> 'Key
-
A function transforming each item of the input sequence into a key to be
compared against the others.
Returns: ('Key * int) seq
The result sequence.
Modifiers: inline Type parameters: '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.
Extended Type:
|
||||||
Full Usage:
this.distinctBy projection
Parameters:
'T -> 'Key
-
A function transforming the sequence items into comparable keys.
Returns: 'T seq
The result sequence.
Modifiers: inline Type parameters: 'Key |
Extended Type:
|
||||||
Full Usage:
this.exactlyOne ()
Parameters:
unit
Returns: 'T
The only element of the sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.exists predicate
Parameters:
'T -> bool
-
A function to test each item of the input sequence.
Returns: bool
True if any result from the predicate is true; false otherwise.
Modifiers: inline |
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.
Extended Type:
|
||||||
Full Usage:
this.filter predicate
Parameters:
'T -> bool
-
A function to test whether each item in the input sequence should be included in the output.
Returns: 'T seq
The result sequence.
Modifiers: inline |
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.
Extended Type:
|
||||||
Full Usage:
this.find predicate
Parameters:
'T -> bool
-
A function to test whether an item in the sequence should be returned.
Returns: 'T
The first element for which the predicate returns true .
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.findBack predicate
Parameters:
'T -> bool
-
A function to test whether an item in the sequence should be returned.
Returns: 'T
The last element for which the predicate returns true .
Modifiers: inline |
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.
Extended Type:
|
||||||
Full Usage:
this.findIndex predicate
Parameters:
'T -> bool
-
A function to test whether the index of a particular element should be returned.
Returns: int
The index of the first element for which the predicate returns true .
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.findIndexBack predicate
Parameters:
'T -> bool
-
A function to test whether the index of a particular element should be returned.
Returns: int
The index of the last element for which the predicate returns true .
Modifiers: inline |
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.
Extended Type:
|
||||||
Full Usage:
this.fold (state, folder)
Parameters:
'State
-
The initial state.
folder : 'State -> 'T -> 'State
-
A function that updates the state with each element from the sequence.
Returns: 'State
The state object after the folding function is applied to each element of the sequence.
Modifiers: inline Type parameters: 'State |
Extended Type:
|
||||||
Full Usage:
this.foldBack (folder, state)
Parameters:
'T -> 'State -> 'State
-
The function to update the state given the input elements.
state : 'State
-
The initial state.
Returns: 'State
The state object after the folding function is applied to each element of the sequence.
Modifiers: inline Type parameters: 'State |
Extended Type:
|
||||||
Full Usage:
this.forall predicate
Parameters:
'T -> bool
-
A function to test an element of the input sequence.
Returns: bool
True if every element of the sequence satisfies the predicate; false otherwise.
Modifiers: inline |
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.
Extended Type:
|
||||||
Full Usage:
this.groupBy projection
Parameters:
'T -> 'Key
-
A function that transforms an element of the sequence into a comparable key.
Returns: ('Key * 'T seq) seq
The result sequence.
Modifiers: inline Type parameters: '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.
Extended Type:
|
||||||
Full Usage:
this.head ()
Parameters:
unit
Returns: 'T
The first element of the sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.indexed ()
Parameters:
unit
Returns: (int * 'T) seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.insertAt (index, value)
Parameters:
int
-
The index where the item should be inserted.
value : 'T
-
The value to insert.
Returns: 'T seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.insertManyAt (index, values)
Parameters:
int
-
The index where the items should be inserted.
values : 'T seq
-
The values to insert.
Returns: 'T seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.iter action
Parameters:
'T -> unit
-
A function to apply to each element of the sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.iteri action
Parameters:
int -> 'T -> unit
-
A function to apply to each element of the sequence that can also access the current index.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.last ()
Parameters:
unit
Returns: 'T
The last element of the sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.length ()
Parameters:
unit
Returns: int
The length of the sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.length
Returns: int
The length of the sequence.
Modifiers: inline abstract |
Extended Type:
|
||||||
Full Usage:
this.map mapping
Parameters:
'T -> 'U
-
A function to transform items from the input sequence.
Returns: 'U seq
The result sequence.
Modifiers: inline Type parameters: 'U |
The returned sequence may be passed between threads safely. However, individual IEnumerator values generated from the returned sequence should not be accessed concurrently.
Extended Type:
|
||||||
Full Usage:
this.mapFold (state, mapping)
Parameters:
'State
-
The initial state.
mapping : 'State -> 'T -> 'Result * 'State
-
The function to transform elements from the input collection and accumulate the final value.
Returns: 'Result seq * 'State
The collection of transformed elements, and the final accumulated value.
Modifiers: inline Type parameters: 'T, 'State, 'Result |
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.
Extended Type:
|
||||||
Full Usage:
this.mapFoldBack (mapping, state)
Parameters:
'T -> 'State -> 'Result * 'State
-
The function to transform elements from the input collection and accumulate the final value.
state : 'State
-
The initial state.
Returns: 'Result seq * 'State
The collection of transformed elements, and the final accumulated value.
Modifiers: inline Type parameters: 'State, 'Result |
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.
Extended Type:
|
||||||
Full Usage:
this.mapi mapping
Parameters:
int -> 'T -> 'U
-
A function to transform items from the input sequence that also supplies the current index.
Returns: 'U seq
The result sequence.
Modifiers: inline Type parameters: 'U |
Extended Type:
|
||||||
Full Usage:
this.pairwise ()
Parameters:
unit
Returns: ('T * 'T) seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.permute indexMap
Parameters:
int -> int
-
The function that maps input indices to output indices.
Returns: 'T seq
The result sequence.
Modifiers: inline |
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.
Extended Type:
|
||||||
Full Usage:
this.pick chooser
Parameters:
'T -> 'U option
-
A function to transform each item of the input sequence into an option of the output type.
Returns: 'U
The selected element.
Modifiers: inline Type parameters: 'U |
Extended Type:
|
||||||
Full Usage:
this.readonly ()
Parameters:
unit
Returns: 'T seq
The result sequence.
Modifiers: inline |
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.
Extended Type:
|
||||||
Full Usage:
this.reduce reduction
Parameters:
'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.
Returns: 'T
The final result of the reduction function.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.reduceBack reduction
Parameters:
'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.
Returns: 'T
The final result of the reductions.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.removeAt index
Parameters:
int
-
The index of the item to be removed.
Returns: 'T seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.removeManyAt (index, count)
Parameters:
int
-
The index of the item to be removed.
count : int
-
The number of items to remove.
Returns: 'T seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.reverse ()
Parameters:
unit
Returns: 'T seq
The reversed sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.scan (state, folder)
Parameters:
'State
-
The initial state.
folder : 'State -> 'T -> 'State
-
A function that updates the state with each element from the sequence.
Returns: 'State seq
The resulting sequence of computed states.
Modifiers: inline Type parameters: 'State |
Extended Type:
|
||||||
Full Usage:
this.scanBack (folder, state)
Parameters:
'T -> 'State -> 'State
-
A function that updates the state with each element from the sequence.
state : 'State
-
The initial state.
Returns: 'State seq
The resulting sequence of computed states.
Modifiers: inline Type parameters: 'State |
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.
Extended Type:
|
||||||
Full Usage:
this.skip count
Parameters:
int
-
The number of items to skip.
Returns: 'T seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.skipWhile predicate
Parameters:
'T -> bool
-
A function that evaluates an element of the sequence to a boolean value.
Returns: 'T seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.sortBy projection
Parameters:
'T -> 'Key
-
A function to transform items of the input sequence into comparable keys.
Returns: 'T seq
The result sequence.
Modifiers: inline Type parameters: '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. This is a stable sort, that is the original order of equal elements is preserved.
Extended Type:
|
||||||
Full Usage:
this.sortByDescending projection
Parameters:
'T -> 'Key
-
A function to transform items of the input sequence into comparable keys.
Returns: 'T seq
The result sequence.
Modifiers: inline Type parameters: '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. This is a stable sort, that is the original order of equal elements is preserved.
Extended Type:
|
||||||
Full Usage:
this.sortWith comparer
Parameters:
'T -> 'T -> int
-
The function to compare the collection elements.
Returns: 'T seq
The result sequence.
Modifiers: inline |
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.
Extended Type:
|
||||||
Full Usage:
this.splitInto count
Parameters:
int
-
The maximum number of chunks.
Returns: 'T[] seq
The sequence split into chunks.
Modifiers: inline |
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.
Extended Type:
|
||||||
Full Usage:
this.tail ()
Parameters:
unit
Returns: 'T seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.take count
Parameters:
int
-
The number of items to take.
Returns: 'T seq
The result sequence.
Modifiers: inline |
Throws
Extended Type:
|
||||||
Full Usage:
this.takeWhile predicate
Parameters:
'T -> bool
-
A function that evaluates to false when no more items should be returned.
Returns: 'T seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.toArray ()
Parameters:
unit
Returns: 'T[]
The result array.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.toList ()
Parameters:
unit
Returns: 'T list
The result list.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
IEnumerable.transpose source
Parameters:
'a seq
Returns: 'T seq seq
The transposed sequence.
Modifiers: inline Type parameters: 'a |
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.
Extended Type:
|
||||||
Full Usage:
this.truncate count
Parameters:
int
-
The maximum number of items to enumerate.
Returns: 'T seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.tryExactlyOne ()
Parameters:
unit
Returns: 'T option
The only element of the sequence or None.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.tryFind predicate
Parameters:
'T -> bool
-
A function that evaluates to a Boolean when given an item in the sequence.
Returns: 'T option
The found element or None .
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.tryFindBack predicate
Parameters:
'T -> bool
-
A function that evaluates to a Boolean when given an item in the sequence.
Returns: 'T option
The found element or None .
Modifiers: inline |
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.
Extended Type:
|
||||||
Full Usage:
this.tryFindIndex predicate
Parameters:
'T -> bool
-
A function that evaluates to a Boolean when given an item in the sequence.
Returns: int option
The found index or None .
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.tryFindIndexBack predicate
Parameters:
'T -> bool
-
A function that evaluates to a Boolean when given an item in the sequence.
Returns: int option
The found index or None .
Modifiers: inline |
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.
Extended Type:
|
||||||
Full Usage:
this.tryHead ()
Parameters:
unit
Returns: 'T option
The first element of the sequence or None.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.tryItem index
Parameters:
int
-
The index of element to retrieve.
Returns: 'T option
The nth element of the sequence or None .
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.tryLast ()
Parameters:
unit
Returns: 'T option
The last element of the sequence or None.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.tryPick chooser
Parameters:
'T -> 'U option
-
A function that transforms items from the input sequence into options.
Returns: 'U option
The chosen element or None .
Modifiers: inline Type parameters: 'U |
Extended Type:
|
||||||
Full Usage:
this.updateAt (index, value)
Parameters:
int
-
The index of the item to be replaced.
value : 'T
-
The new value.
Returns: 'T seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.where predicate
Parameters:
'T -> bool
-
A function to test whether each item in the input sequence should be included in the output.
Returns: 'T seq
The result sequence.
Modifiers: inline |
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.
Extended Type:
|
||||||
Full Usage:
this.windowed windowSize
Parameters:
int
-
The number of elements in each window.
Returns: 'T[] seq
The result sequence.
Modifiers: inline |
Extended Type:
|
||||||
Full Usage:
this.zip source2
Parameters:
'T2 seq
-
The second input sequence.
Returns: ('T * 'T2) seq
The result sequence.
Modifiers: inline Type parameters: 'T2 |
Extended Type:
|
||||||
Full Usage:
this.zip3 (source2, source3)
Parameters:
'T2 seq
-
The second input sequence.
source3 : 'T3 seq
-
The third input sequence.
Returns: ('T * 'T2 * 'T3) seq
The result sequence.
Modifiers: inline Type parameters: 'T2, 'T3 |
Extended Type:
|