Provides parallel operations on arrays
Function or value | Description | ||||
Full Usage:
Array.Parallel.average array
Parameters:
^T[]
-
The input array.
Returns: ^T
The average of the elements in the array.
Modifiers: inline Type parameters: ^T |
Example
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to 3.0
Example
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Throws ArgumentException
|
||||
Full Usage:
Array.Parallel.averageBy projection array
Parameters:
'T -> ^U
-
The function to transform the array elements before averaging.
array : 'T[]
-
The input array.
Returns: ^U
The computed average.
Modifiers: inline Type parameters: 'T, ^U |
Example
type Foo =
{ Bar: float }
Foo.Bar: float
Multiple items
val float: value: 'T -> float (requires member op_Explicit) -------------------- type float = System.Double -------------------- type float<'Measure> = float val input: Foo array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to 3.0
Example
type Foo =
{ Bar: float }
Foo.Bar: float
Multiple items
val float: value: 'T -> float (requires member op_Explicit) -------------------- type float = System.Double -------------------- type float<'Measure> = float val input: Foo array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Throws ArgumentException
|
||||
Full Usage:
Array.Parallel.choose chooser array
Parameters:
'T -> 'U option
-
The function to generate options from the elements.
array : 'T[]
-
The input array.
Returns: 'U[]
The array of results.
|
Performs the operation in parallel using Parallel.For. The order in which the given function is applied to elements of the input array is not specified.
Example
val input: int option array
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
val choose: chooser: ('T -> 'U option) -> array: 'T array -> 'U array
val id: x: 'T -> 'T
Evaluates to [| 1; 2 |]
Example
val input: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
val choose: chooser: ('T -> 'U option) -> array: 'T array -> 'U array
val n: int
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
Evaluates to [| 2 |]
|
||||
Full Usage:
Array.Parallel.collect mapping array
Parameters:
'T -> 'U[]
-
array : 'T[]
-
The input array.
Returns: 'U[]
'U[]
|
Performs the operation in parallel using Parallel.For. The order in which the given function is applied to elements of the input array is not specified.
Example
type Foo =
{ Bar: int array }
Foo.Bar: int array
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int val input: Foo array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
val collect: mapping: ('T -> 'U array) -> array: 'T array -> 'U array
val foo: Foo
Evaluates to [| 1; 2; 3; 4 |]
Example
val input: int array array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
val collect: mapping: ('T -> 'U array) -> array: 'T array -> 'U array
val id: x: 'T -> 'T
Evaluates to [| 1; 2; 3; 4 |]
|
||||
|
The predicate is applied to the elements of the input array in parallel. If any application
returns true then the overall result is true and testing of other elements in all threads is stopped at system's earliest convenience.
Otherwise,
Example
val input: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to true
Example
val input: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to false
|
||||
Full Usage:
Array.Parallel.filter predicate array
Parameters:
'T -> bool
-
The function to test the input elements.
array : 'T[]
-
The input array.
Returns: 'T[]
An array containing the elements for which the given predicate returns true.
|
Example
val inputs: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to [| 2; 4 |]
|
||||
|
The predicate is applied to the elements of the input collection in parallel. If any application returns false then the overall result is false and testing of other elements in all threads is stopped at system's earliest convenience. Otherwise, true is returned.
Example
val isEven: a: int -> bool
val a: int
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
|
||||
Full Usage:
Array.Parallel.groupBy projection array
Parameters:
'T -> 'Key
-
A function that transforms an element of the array into a comparable key.
array : 'T[]
-
The input array.
Returns: ('Key * 'T[])[]
The result array.
|
Performs the operation in parallel using Parallel.For. The order in which the given function is applied to elements of the input array is not specified. The order of the keys and values in the result is also not specified
Example
val inputs: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to [| (1, [| 1; 3; 5 |]); (0, [| 2; 4 |]) |]
|
||||
|
Performs the operation in parallel using Parallel.For. The order in which the given function is applied to indices is not specified.
Example
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
val init: count: int -> initializer: (int -> 'T) -> 'T array
val v: int
Evaluates to [| 5; 6; 7; 8 |]
|
||||
Full Usage:
Array.Parallel.iter action array
Parameters:
'T -> unit
-
array : 'T[]
-
The input array.
|
Performs the operation in parallel using Parallel.For. The order in which the given function is applied to elements of the input array is not specified.
Example
val inputs: string array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
val iter: action: ('T -> unit) -> array: 'T array -> unit
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Evaluates to unit and prints the following to the console in an unspecified order:
|
||||
|
Performs the operation in parallel using Parallel.For. The order in which the given function is applied to elements of the input array is not specified.
Example
val inputs: string array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
val iteri: action: (int -> 'T -> unit) -> array: 'T array -> unit
val i: int
val v: string
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Evaluates to unit and prints the following to the console in an unspecified order:
|
||||
Full Usage:
Array.Parallel.map mapping array
Parameters:
'T -> 'U
-
array : 'T[]
-
The input array.
Returns: 'U[]
The array of results.
|
Performs the operation in parallel using Parallel.For. The order in which the given function is applied to elements of the input array is not specified.
Example
val inputs: string array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
val map: mapping: ('T -> 'U) -> array: 'T array -> 'U array
val x: string
property System.String.Length: int with get
Evaluates to [| 1; 3; 2 |]
|
||||
Full Usage:
Array.Parallel.mapi mapping array
Parameters:
int -> 'T -> 'U
-
array : 'T[]
-
The input array.
Returns: 'U[]
The array of results.
|
Performs the operation in parallel using Parallel.For. The order in which the given function is applied to elements of the input array is not specified.
Example
val inputs: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
val mapi: mapping: (int -> 'T -> 'U) -> array: 'T array -> 'U array
val i: int
val x: int
Evaluates to [| 10; 11; 12 |]
|
||||
Full Usage:
Array.Parallel.max array
Parameters:
'T[]
-
The input array.
Returns: 'T
The maximum element.
Modifiers: inline Type parameters: 'T |
Throws ArgumentException for empty arrays.
Example
val inputs: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to 12
Example
val inputs: int array
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Throws System.ArgumentException .
|
||||
Full Usage:
Array.Parallel.maxBy projection array
Parameters:
'T -> 'U
-
The function to transform the elements into a type supporting comparison.
array : 'T[]
-
The input array.
Returns: 'T
The maximum element.
Modifiers: inline Type parameters: 'T, 'U |
Throws ArgumentException for empty arrays.
Example
val inputs: string array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to "cccc"
Example
val inputs: string array
Multiple items
val string: value: 'T -> string -------------------- type string = System.String module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Throws System.ArgumentException .
|
||||
Full Usage:
Array.Parallel.min array
Parameters:
'T[]
-
The input array.
Returns: 'T
The minimum element.
Modifiers: inline Type parameters: 'T |
Throws ArgumentException for empty arrays
Example
val inputs: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to 10
Example
val inputs: int array
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Throws System.ArgumentException .
|
||||
Full Usage:
Array.Parallel.minBy projection array
Parameters:
'T -> 'U
-
The function to transform the elements into a type supporting comparison.
array : 'T[]
-
The input array.
Returns: 'T
The minimum element.
Modifiers: inline Type parameters: 'T, 'U |
Throws ArgumentException for empty arrays.
Example
val inputs: string array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to "b"
Example
val inputs: string array
Multiple items
val string: value: 'T -> string -------------------- type string = System.String module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Throws System.ArgumentException .
|
||||
Full Usage:
Array.Parallel.partition predicate array
Parameters:
'T -> bool
-
The function to test the input elements.
array : 'T[]
-
The input array.
Returns: 'T[] * 'T[]
The two arrays of results.
|
Performs the operation in parallel using Parallel.For. The order in which the given function is applied to indices is not specified.
Example
val inputs: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
val partition: predicate: ('T -> bool) -> array: 'T array -> 'T array * 'T array
val x: int
Evaluates to ([|2; 4|], [|1; 3|]) .
|
||||
Full Usage:
Array.Parallel.reduce reduction array
Parameters:
'T -> 'T -> 'T
-
The function to reduce a pair of elements to a single element.
array : 'T[]
-
The input array.
Returns: 'T
Result of the reductions.
Modifiers: inline Type parameters: 'T |
The order of processing is not guaranteed. For that reason, the 'reduce' function argument should be commutative. (That is, changing the order of execution must not affect the result) Also, compared to the non-parallel version of Array.reduce, the 'reduce' function may be invoked more times due to the resulting reduction from participating threads.
Example
val inputs: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to 1 + 3 + 4 + 2 . However, the system could have decided to compute (1+3) and (4+2) first, and then put them together.
|
||||
Full Usage:
Array.Parallel.reduceBy projection reduction array
Parameters:
'T -> 'U
-
The function to project from elements of the input array
reduction : 'U -> 'U -> 'U
-
The function to reduce a pair of projected elements to a single element.
array : 'T[]
-
The input array.
Returns: 'U
The final result of the reductions.
|
The order of processing is not guaranteed. For that reason, the 'reduction' function argument should be commutative. (That is, changing the order of execution must not affect the result)
Example
val inputs: string array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Multiple items
Evaluates to val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int 1 + 3 + 4 + 2 . However, the system could have decided to compute (1+3) and (4+2) first, and then put them together.
|
||||
Full Usage:
Array.Parallel.sort array
Parameters:
'T[]
-
The input array.
Returns: 'T[]
The sorted array.
|
![]() ![]() ![]() ![]() ![]() ![]() Sorts the elements of an array in parallel, returning a new array. Elements are compared using Operators.compare. This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. For a stable sort, consider using Seq.Sort.
Example
val input: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to [| 1; 1 3; 4; 6; 8 |] .
|
||||
Full Usage:
Array.Parallel.sortBy projection array
Parameters:
'T -> 'Key
-
The function to transform array elements into the type that is compared.
array : 'T[]
-
The input array.
Returns: 'T[]
The sorted array.
|
![]() ![]() ![]() ![]() ![]() ![]() Sorts the elements of an array in parallel, using the given projection for the keys and returning a new array. Elements are compared using Operators.compare. This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. For a stable sort, consider using Seq.Sort.
Example
val input: string array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to [|"a"; "dd"; "bbb"; "cccc"|] .
|
||||
Full Usage:
Array.Parallel.sortByDescending projection array
Parameters:
'T -> 'Key
-
The function to transform array elements into the type that is compared.
array : 'T[]
-
The input array.
Returns: 'T[]
The sorted array.
|
![]() ![]() ![]() ![]() ![]() ![]() Sorts the elements of an array in parallel, in descending order, using the given projection for the keys and returning a new array. Elements are compared using Operators.compare. This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. For a stable sort, consider using Seq.Sort.
Example
val input: string array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to [|"cccc"; "bbb"; "dd"; "a"|] .
|
||||
Full Usage:
Array.Parallel.sortDescending array
Parameters:
'T[]
-
The input array.
Returns: 'T[]
The sorted array.
|
![]() ![]() ![]() ![]() ![]() ![]() Sorts the elements of an array in parallel, in descending order, returning a new array. Elements are compared using Operators.compare. This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. For a stable sort, consider using Seq.Sort.
Example
val input: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to [| 8; 6; 4; 3; 1; 1 |] .
|
||||
Full Usage:
Array.Parallel.sortInPlace array
Parameters:
'T[]
-
The input array.
|
![]() ![]() ![]() ![]() ![]() ![]() Sorts the elements of an array by mutating the array in-place in parallel, using the given comparison function. Elements are compared using Operators.compare.
Example
Multiple items
val array: int array -------------------- type 'T array = 'T array module Array
from Microsoft.FSharp.Collections
val sortInPlace: array: 'T array -> unit (requires comparison)
After evaluation array contains [| 1; 1; 3; 4; 6; 8 |] .
|
||||
Full Usage:
Array.Parallel.sortInPlaceBy projection array
Parameters:
'T -> 'Key
-
The function to transform array elements into the type that is compared.
array : 'T[]
-
The input array.
|
![]() ![]() ![]() ![]() ![]() ![]() Sorts the elements of an array by mutating the array in-place in parallel, using the given projection for the keys. Elements are compared using Operators.compare. This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. For a stable sort, consider using Seq.Sort.
Example
Multiple items
val array: string array -------------------- type 'T array = 'T array module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
After evaluation array contains [|"a"; "dd"; "bbb"; "cccc"|] .
|
||||
Full Usage:
Array.Parallel.sortInPlaceWith comparer array
Parameters:
'T -> 'T -> int
-
The function to compare pairs of array elements.
array : 'T[]
-
The input array.
|
ExampleThe following sorts entries using a comparison function that compares string lengths then index numbers:
val compareEntries: n1: int * s1: string -> n2: int * s2: string -> int
val n1: int
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int val s1: string
Multiple items
val string: value: 'T -> string -------------------- type string = System.String val n2: int
val s2: string
val c: int
val compare: e1: 'T -> e2: 'T -> int (requires comparison)
property System.String.Length: int with get
Multiple items
val array: (int * string) array -------------------- type 'T array = 'T array module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
After evaluation array contains [|(0, "aa"); (2, "cc"); (3, "dd"); (1, "bbb")|] .
|
||||
Full Usage:
Array.Parallel.sortWith comparer array
Parameters:
'T -> 'T -> int
-
The function to compare pairs of array elements.
array : 'T[]
-
The input array.
Returns: 'T[]
The sorted array.
|
This is not a stable sort, i.e. the original order of equal elements is not necessarily preserved. For a stable sort, consider using Seq.Sort.
ExampleSort an array of pairs using a comparison function that compares string lengths then index numbers:
val compareEntries: n1: int * s1: string -> n2: int * s2: string -> int
val n1: int
Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int val s1: string
Multiple items
val string: value: 'T -> string -------------------- type string = System.String val n2: int
val s2: string
val c: int
val compare: e1: 'T -> e2: 'T -> int (requires comparison)
property System.String.Length: int with get
val input: (int * string) array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to [|(0, "aa"); (2, "cc"); (3, "dd"); (1, "bbb")|] .
|
||||
Full Usage:
Array.Parallel.sum array
Parameters:
^T[]
-
The input array.
Returns: ^T
The resulting sum.
Modifiers: inline Type parameters: ^T |
Example
val input: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to 11 .
|
||||
Full Usage:
Array.Parallel.sumBy projection array
Parameters:
'T -> ^U
-
The function to transform the array elements into the type to be summed.
array : 'T[]
-
The input array.
Returns: ^U
The resulting sum.
Modifiers: inline Type parameters: 'T, ^U |
Example
val input: string array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to 7 .
|
||||
|
ExampleTry to find the first even number:
val inputs: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to Some 2 .
ExampleTry to find the first even number:
val inputs: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to None
|
||||
|
ExampleTry to find the index of the first even number:
val inputs: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to Some 1
ExampleTry to find the index of the first even number:
val inputs: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to None
|
||||
|
Example
val input: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
union case Option.Some: Value: 'T -> Option<'T>
Multiple items
val string: value: 'T -> string -------------------- type string = System.String union case Option.None: Option<'T>
Evaluates to Some 2 .
Example
val input: int array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
union case Option.Some: Value: 'T -> Option<'T>
Multiple items
val string: value: 'T -> string -------------------- type string = System.String union case Option.None: Option<'T>
Evaluates to None .
|
||||
Full Usage:
Array.Parallel.zip array1 array2
Parameters:
'T1[]
-
The first input array.
array2 : 'T2[]
-
The second input array.
Returns: ('T1 * 'T2)[]
The array of tupled elements.
|
Example
val numbers: int array
val names: string array
module Array
from Microsoft.FSharp.Collections
module Parallel
from Microsoft.FSharp.Collections.ArrayModule
Evaluates to [| (1, "one"); (2, "two") |] .
|