Specialized Module
Contains specialized overloads of for
and yield!
that give increased iteration performance
for common collection types at the cost of requiring that the type of the collection being iterated be statically known.
Example
The type of xs
must be annotated or otherwise known,
but once it is, the appropriate specialized iteration technique
will be used.
let f (xs : int list) =
resizeArray {
for x in xs -> x * x
}
val int: value: 'T -> int (requires member op_Explicit)
--------------------
type int = int32
--------------------
type int<'Measure> = int
xs
is known to be a list because of the call to List.length
.
let g xs =
let len = List.length xs
resizeArray {
for x in xs -> x * len
}
module List from Microsoft.FSharp.Collections
--------------------
type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ...
Functions and values
Function or value |
Description
|
|
Builds a collection of the inferred or specified type using computation expression syntax.
Example
val xs: int array
val ys: obj
type ResizeArray<'T> = System.Collections.Generic.List<'T>
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int val zs: obj
val xs: int array
val ys: ResizeArray<int>
type ResizeArray<'T> = System.Collections.Generic.List<'T>
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int val zs: obj
|
|
Builds a dictionary of the inferred or specified type using computation expression syntax.
Example
val m: obj
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int
val m: obj
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int |
|
Builds a Dictionary using computation expression syntax.
Example
val m: obj
|
|
Builds a HashSet using computation expression syntax.
Example
val xs: obj
|
|
Builds an ImmutableArray using computation expression syntax.
Example
val xs: obj
|
|
Builds an ImmutableDictionary using computation expression syntax.
Example
val m: obj
|
|
Builds an ImmutableHashSet using computation expression syntax.
Example
val xs: obj
|
|
Builds an ImmutableList using computation expression syntax.
Example
val xs: obj
|
|
Builds an ImmutableSortedDictionary using computation expression syntax.
Example
val m: obj
|
|
Builds an ImmutableSortedSet using computation expression syntax.
Example
val xs: obj
|
|
Builds a Map using computation expression syntax.
Example
val m: obj
|
|
Builds a List using computation expression syntax.
Example
val f: xs: int list -> 'a
val xs: int list
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int type 'T list = List<'T>
val a: int
val xs: int array
val ys: obj
|
|
Builds a Set using computation expression syntax.
Example
val xs: obj
|
|
Builds a SortedDictionary using computation expression syntax.
Example
val m: obj
|
|
Builds a SortedSet using computation expression syntax.
Example
val xs: obj
|
|
Computes a sum using computation expression syntax.
Example
val s: obj
val xs: int list
val s: obj
val xs: int list
val s: obj
|
|
Computes a sum using computation expression syntax.
Example
val s: obj
val xs: int list
val s: obj
val xs: int list
val s: obj
|
Type extensions
Type extension |
Description
|
Full Usage:
this.For
Parameters:
'a seq
body : 'a -> CollectionBuilderCode<'b>
Returns: CollectionBuilderCode<'b>
Modifiers: inline Type parameters: 'a, 'b |
Extended Type:
|
Full Usage:
this.For
Parameters:
'a list
body : 'a -> CollectionBuilderCode<'b>
Returns: CollectionBuilderCode<'b>
Modifiers: inline Type parameters: 'a, 'b |
Extended Type:
|
Full Usage:
this.For
Parameters:
'a array
body : 'a -> CollectionBuilderCode<'b>
Returns: CollectionBuilderCode<'b>
Modifiers: inline Type parameters: 'a, 'b |
Extended Type:
|
Full Usage:
this.For
Parameters:
Set<'a>
body : 'a -> CollectionBuilderCode<'b>
Returns: CollectionBuilderCode<'b>
Modifiers: inline Type parameters: 'a, 'b |
Extended Type:
|
Full Usage:
this.For
Parameters:
Map<'a, 'b>
body : 'a * 'b -> CollectionBuilderCode<'c>
Returns: CollectionBuilderCode<'c>
Modifiers: inline Type parameters: 'a, 'b, 'c |
Extended Type:
|
Full Usage:
this.For
Parameters:
ResizeArray<'a>
body : 'a -> CollectionBuilderCode<'b>
Returns: CollectionBuilderCode<'b>
Modifiers: inline Type parameters: 'a, 'b |
Extended Type:
|
Full Usage:
this.For
Parameters:
ImmutableArray<'a>
body : 'a -> CollectionBuilderCode<'b>
Returns: CollectionBuilderCode<'b>
Modifiers: inline Type parameters: 'a, 'b |
Extended Type:
|
Full Usage:
this.For
Parameters:
Builder<'a>
body : 'a -> CollectionBuilderCode<'b>
Returns: CollectionBuilderCode<'b>
Modifiers: inline Type parameters: 'a, 'b |
Extended Type:
|
Full Usage:
this.For
Parameters:
Span<'a>
body : 'a -> CollectionBuilderCode<^b>
Returns: CollectionBuilderCode<^c>
Modifiers: inline Type parameters: 'a, ^b, ^c |
Extended Type:
|
Full Usage:
this.For
Parameters:
ReadOnlySpan<'a>
body : 'a -> CollectionBuilderCode<^b>
Returns: CollectionBuilderCode<^c>
Modifiers: inline Type parameters: 'a, ^b, ^c |
Extended Type:
|
Full Usage:
this.YieldFrom
Parameters:
'a seq
Returns: CollectionBuilderCode<^b>
Modifiers: inline Type parameters: 'a, ^b, 'c |
|
Full Usage:
this.YieldFrom
Parameters:
'a list
Returns: CollectionBuilderCode<^b>
Modifiers: inline Type parameters: 'a, ^b, 'c |
|
Full Usage:
this.YieldFrom
Parameters:
'a array
Returns: CollectionBuilderCode<^b>
Modifiers: inline Type parameters: 'a, ^b, 'c |
|
Full Usage:
this.YieldFrom
Parameters:
ResizeArray<'a>
Returns: CollectionBuilderCode<^b>
Modifiers: inline Type parameters: 'a, ^b, 'c |
|
Full Usage:
this.YieldFrom
Parameters:
Set<'a>
Returns: CollectionBuilderCode<^b>
Modifiers: inline Type parameters: 'a, ^b, 'c |
|
Full Usage:
this.YieldFrom
Parameters:
Map<'a, 'b>
Returns: CollectionBuilderCode<^c>
Modifiers: inline Type parameters: 'a, 'b, ^c, 'd |
|
Full Usage:
this.YieldFrom
Parameters:
ImmutableArray<'a>
Returns: CollectionBuilderCode<^b>
Modifiers: inline Type parameters: 'a, ^b, 'c |
|
Full Usage:
this.YieldFrom
Parameters:
('a * 'b) seq
Returns: CollectionBuilderCode<^c>
Modifiers: inline Type parameters: 'a, 'b, ^c, 'd |
|
Full Usage:
this.YieldFrom
Parameters:
('a * 'b) list
Returns: CollectionBuilderCode<^c>
Modifiers: inline Type parameters: 'a, 'b, ^c, 'd |
|
Full Usage:
this.YieldFrom
Parameters:
('a * 'b) array
Returns: CollectionBuilderCode<^c>
Modifiers: inline Type parameters: 'a, 'b, ^c, 'd |
|
Full Usage:
this.YieldFrom
Parameters:
ResizeArray<'a * 'b>
Returns: CollectionBuilderCode<^c>
Modifiers: inline Type parameters: 'a, 'b, ^c, 'd |
|
Full Usage:
this.YieldFrom
Parameters:
Set<'a * 'b>
Returns: CollectionBuilderCode<^c>
Modifiers: inline Type parameters: 'a, 'b, ^c, 'd |
|
Full Usage:
this.YieldFrom
Parameters:
Map<'a, 'b>
Returns: CollectionBuilderCode<^c>
Modifiers: inline Type parameters: 'a, 'b, ^c, 'd |
|
Full Usage:
this.YieldFrom
Parameters:
ImmutableArray<'a * 'b>
Returns: CollectionBuilderCode<^c>
Modifiers: inline Type parameters: 'a, 'b, ^c, 'd |