Header menu logo FSharp.Core

Array.Parallel Module

Provides parallel operations on arrays

Functions and values

Function or value Description

Array.Parallel.average array

Full Usage: Array.Parallel.average array

Parameters:
    array : ^T array - The input array.

Returns: ^T The average of the elements in the array.
Modifiers: inline
Type parameters: ^T

Returns the average of the elements in the array.

array : ^T array

The input array.

Returns: ^T

The average of the elements in the array.

ArgumentException Thrown when array is empty.
ArgumentNullException Thrown when the input array is null.
Example

 [| 1.0; 2.0; 6.0 |] |> Array.Parallel.average
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val average: array: 'T array -> 'T (requires member (+) and member DivideByInt)
Evaluates to 3.0

Example

 [| |] |> Array.Parallel.average
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val average: array: 'T array -> 'T (requires member (+) and member DivideByInt)
Throws ArgumentException

Array.Parallel.averageBy projection array

Full Usage: Array.Parallel.averageBy projection array

Parameters:
    projection : 'T -> ^U - The function to transform the array elements before averaging.
    array : 'T array - The input array.

Returns: ^U The computed average.
Modifiers: inline
Type parameters: 'T, ^U

Returns the average of the elements generated by applying the function to each element of the array.

projection : 'T -> ^U

The function to transform the array elements before averaging.

array : 'T array

The input array.

Returns: ^U

The computed average.

ArgumentException Thrown when array is empty.
ArgumentNullException Thrown when the input array is null.
Example

 type Foo = { Bar: float }

 let input = [| {Bar = 2.0}; {Bar = 4.0} |]

 input |> Array.Parallel.averageBy (fun foo -> foo.Bar)
type 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
val averageBy: projection: ('T -> 'U) -> array: 'T array -> 'U (requires member (+) and member DivideByInt)
val foo: Foo
Foo.Bar: float
Evaluates to 3.0

Example

 type Foo = { Bar: float }

 let input : Foo array = [| |]

 input |> Array.Parallel.averageBy (fun foo -> foo.Bar)
type 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
type 'T array = 'T array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val averageBy: projection: ('T -> 'U) -> array: 'T array -> 'U (requires member (+) and member DivideByInt)
val foo: Foo
Foo.Bar: float
Throws ArgumentException

Array.Parallel.choose chooser array

Full Usage: Array.Parallel.choose chooser array

Parameters:
    chooser : 'T -> 'U option - The function to generate options from the elements.
    array : 'T array - The input array.

Returns: 'U array The array of results.

Apply the given function to each element of the array. Return the array comprised of the results x for each element where the function returns Some(x).

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.

chooser : 'T -> 'U option

The function to generate options from the elements.

array : 'T array

The input array.

Returns: 'U array

The array of results.

ArgumentNullException Thrown when the input array is null.
Example

 let input = [| Some 1; None; Some 2 |]

 input |> Array.Parallel.choose id
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

 let input = [| 1; 2; 3 |]

 input |> Array.Parallel.choose (fun n -> if n % 2 = 0 then Some n else None)
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 |]

Array.Parallel.collect mapping array

Full Usage: Array.Parallel.collect mapping array

Parameters:
    mapping : 'T -> 'U array -
    array : 'T array - The input array.

Returns: 'U array 'U array

For each element of the array, apply the given function. Concatenate all the results and return the combined 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.

mapping : 'T -> 'U array

array : 'T array

The input array.

Returns: 'U array

'U array

ArgumentNullException Thrown when the input array is null.
Example

 type Foo = { Bar: int array }

 let input = [| {Bar = [| 1; 2 |]}; {Bar = [| 3; 4 |]} |]

 input |> Array.Parallel.collect (fun foo -> foo.Bar)
type Foo = { Bar: int array }
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
type 'T array = 'T array
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
Foo.Bar: int array
Evaluates to [| 1; 2; 3; 4 |]

Example

 let input = [| [| 1; 2 |]; [| 3; 4 |] |]

 input |> Array.Parallel.collect id
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 |]

Array.Parallel.exists predicate array

Full Usage: Array.Parallel.exists predicate array

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    array : 'T array - The input array.

Returns: bool True if any result from predicate is true.

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

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, false is returned.

predicate : 'T -> bool

The function to test the input elements.

array : 'T array

The input array.

Returns: bool

True if any result from predicate is true.

ArgumentNullException Thrown when the input array is null.
Example

 let input = [| 1; 2; 3; 4; 5 |]

 input |> Array.Parallel.exists (fun elm -> elm % 4 = 0)
val input: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val exists: predicate: ('T -> bool) -> array: 'T array -> bool
val elm: int
Evaluates to true

Example

 let input = [| 1; 2; 3; 4; 5 |]

 input |> Array.Parallel.exists (fun elm -> elm % 6 = 0)
val input: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val exists: predicate: ('T -> bool) -> array: 'T array -> bool
val elm: int
Evaluates to false

Array.Parallel.filter predicate array

Full Usage: Array.Parallel.filter predicate array

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    array : 'T array - The input array.

Returns: 'T array An array containing the elements for which the given predicate returns true.

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

predicate : 'T -> bool

The function to test the input elements.

array : 'T array

The input array.

Returns: 'T array

An array containing the elements for which the given predicate returns true.

ArgumentNullException Thrown when the input array is null.
Example

 let inputs = [| 1; 2; 3; 4 |]

 inputs |> Array.Parallel.filter (fun elm -> elm % 2 = 0)
val inputs: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val filter: predicate: ('T -> bool) -> array: 'T array -> 'T array
val elm: int
Evaluates to [| 2; 4 |]

Array.Parallel.forall predicate array

Full Usage: Array.Parallel.forall predicate array

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    array : 'T array - The input array.

Returns: bool True if all of the array elements satisfy the predicate.

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

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.

predicate : 'T -> bool

The function to test the input elements.

array : 'T array

The input array.

Returns: bool

True if all of the array elements satisfy the predicate.

ArgumentNullException Thrown when the input array is null.
Example

 let isEven a = a % 2 = 0

 [2; 42] |> Array.Parallel.forall isEven // evaluates to true

 [1; 2] |> Array.Parallel.forall isEven // evaluates to false
val isEven: a: int -> bool
val a: int
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val forall: predicate: ('T -> bool) -> array: 'T array -> bool

Array.Parallel.groupBy projection array

Full Usage: Array.Parallel.groupBy projection array

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

Returns: ('Key * 'T array) array The result array.

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

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

projection : 'T -> 'Key

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

array : 'T array

The input array.

Returns: ('Key * 'T array) array

The result array.

ArgumentNullException Thrown when the input array is null.
Example

 let inputs = [| 1; 2; 3; 4; 5 |]

 inputs |> Array.Parallel.groupBy (fun n -> n % 2)
val inputs: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val groupBy: projection: ('T -> 'Key) -> array: 'T array -> ('Key * 'T array) array (requires equality)
val n: int
Evaluates to [| (1, [| 1; 3; 5 |]); (0, [| 2; 4 |]) |]

Array.Parallel.init count initializer

Full Usage: Array.Parallel.init count initializer

Parameters:
    count : int -
    initializer : int -> 'T -

Returns: 'T array The array of results.

Create an array given the dimension and a generator function to compute the elements.

Performs the operation in parallel using Parallel.For. The order in which the given function is applied to indices is not specified.

count : int

initializer : int -> 'T

Returns: 'T array

The array of results.

Example

 Array.Parallel.init 4 (fun v -> v + 5)
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 |]

Array.Parallel.iter action array

Full Usage: Array.Parallel.iter action array

Parameters:
    action : 'T -> unit -
    array : 'T array - The input array.

Apply the given function to each element of the 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.

action : 'T -> unit

array : 'T array

The input array.

ArgumentNullException Thrown when the input array is null.
Example

 let inputs = [| "a"; "b"; "c" |]

 inputs |> Array.Parallel.iter (printfn "%s")
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:
 a
 c
 b

Array.Parallel.iteri action array

Full Usage: Array.Parallel.iteri action array

Parameters:
    action : int -> 'T -> unit -
    array : 'T array - The input array.

Apply the given function to each element of the array. The integer passed to the function indicates the index of element.

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.

action : int -> 'T -> unit

array : 'T array

The input array.

ArgumentNullException Thrown when the input array is null.
Example

 let inputs = [| "a"; "b"; "c" |]

 inputs |> Array.Parallel.iteri (fun i v -> printfn "{i}: {v}")
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:
 0: a
 2: c
 1: b

Array.Parallel.map mapping array

Full Usage: Array.Parallel.map mapping array

Parameters:
    mapping : 'T -> 'U -
    array : 'T array - The input array.

Returns: 'U array The array of results.

Build a new array whose elements are the results of applying the given function to each of the elements of the 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.

mapping : 'T -> 'U

array : 'T array

The input array.

Returns: 'U array

The array of results.

ArgumentNullException Thrown when the input array is null.
Example

 let inputs = [| "a"; "bbb"; "cc" |]

 inputs |> Array.Parallel.map (fun x -> x.Length)
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 |]

Array.Parallel.mapi mapping array

Full Usage: Array.Parallel.mapi mapping array

Parameters:
    mapping : int -> 'T -> 'U -
    array : 'T array - The input array.

Returns: 'U array The array of results.

Build a new array whose elements are the results of applying the given function to each of the elements of the array. The integer index passed to the function indicates the index of element being transformed.

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.

mapping : int -> 'T -> 'U

array : 'T array

The input array.

Returns: 'U array

The array of results.

ArgumentNullException Thrown when the input array is null.
Example

 let inputs = [| 10; 10; 10 |]

 inputs |> Array.Parallel.mapi (fun i x -> i + x)
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 |]

Array.Parallel.max array

Full Usage: Array.Parallel.max array

Parameters:
    array : 'T array - The input array.

Returns: 'T The maximum element.
Modifiers: inline
Type parameters: 'T

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

Throws ArgumentException for empty arrays.

array : 'T array

The input array.

Returns: 'T

The maximum element.

ArgumentNullException Thrown when the input array is null.
ArgumentException Thrown when the input array is empty.
Example

 let inputs = [| 10; 12; 11 |]

 inputs |> Array.Parallel.max
val inputs: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val max: array: 'T array -> 'T (requires comparison)
Evaluates to 12

Example

 let inputs: int array= [| |]

 inputs |> Array.Parallel.max
val inputs: int array
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
type 'T array = 'T array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val max: array: 'T array -> 'T (requires comparison)
Throws System.ArgumentException.

Array.Parallel.maxBy projection array

Full Usage: Array.Parallel.maxBy projection array

Parameters:
    projection : 'T -> 'U - The function to transform the elements into a type supporting comparison.
    array : 'T array - The input array.

Returns: 'T The maximum element.
Modifiers: inline
Type parameters: 'T, 'U

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

Throws ArgumentException for empty arrays.

projection : 'T -> 'U

The function to transform the elements into a type supporting comparison.

array : 'T array

The input array.

Returns: 'T

The maximum element.

ArgumentNullException Thrown when the input array is null.
ArgumentException Thrown when the input array is empty.
Example

 let inputs = [| "aaa"; "b"; "cccc" |]

 inputs |> Array.Parallel.maxBy (fun s -> s.Length)
val inputs: string array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val maxBy: projection: ('T -> 'U) -> array: 'T array -> 'T (requires comparison)
val s: string
property System.String.Length: int with get
Evaluates to "cccc"

Example

 let inputs: string array= [| |]

 inputs |> Array.Parallel.maxBy (fun s -> s.Length)
val inputs: string array
Multiple items
val string: value: 'T -> string

--------------------
type string = System.String
type 'T array = 'T array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val maxBy: projection: ('T -> 'U) -> array: 'T array -> 'T (requires comparison)
val s: string
property System.String.Length: int with get
Throws System.ArgumentException.

Array.Parallel.min array

Full Usage: Array.Parallel.min array

Parameters:
    array : 'T array - The input array.

Returns: 'T The minimum element.
Modifiers: inline
Type parameters: 'T

Returns the smallest of all elements of the array, compared via Operators.min.

Throws ArgumentException for empty arrays

array : 'T array

The input array.

Returns: 'T

The minimum element.

ArgumentNullException Thrown when the input array is null.
ArgumentException Thrown when the input array is empty.
Example

 let inputs = [| 10; 12; 11 |]

 inputs |> Array.Parallel.min
val inputs: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val min: array: 'T array -> 'T (requires comparison)
Evaluates to 10

Example

 let inputs: int array= [| |]

 inputs |> Array.Parallel.min
val inputs: int array
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
type 'T array = 'T array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val min: array: 'T array -> 'T (requires comparison)
Throws System.ArgumentException.

Array.Parallel.minBy projection array

Full Usage: Array.Parallel.minBy projection array

Parameters:
    projection : 'T -> 'U - The function to transform the elements into a type supporting comparison.
    array : 'T array - The input array.

Returns: 'T The minimum element.
Modifiers: inline
Type parameters: 'T, 'U

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

Throws ArgumentException for empty arrays.

projection : 'T -> 'U

The function to transform the elements into a type supporting comparison.

array : 'T array

The input array.

Returns: 'T

The minimum element.

ArgumentNullException Thrown when the input array is null.
ArgumentException Thrown when the input array is empty.
Example

 let inputs = [| "aaa"; "b"; "cccc" |]

 inputs |> Array.Parallel.minBy (fun s -> s.Length)
val inputs: string array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val minBy: projection: ('T -> 'U) -> array: 'T array -> 'T (requires comparison)
val s: string
property System.String.Length: int with get
Evaluates to "b"

Example

 let inputs: string array= [| |]

 inputs |> Array.Parallel.minBy (fun s -> s.Length)
val inputs: string array
Multiple items
val string: value: 'T -> string

--------------------
type string = System.String
type 'T array = 'T array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val minBy: projection: ('T -> 'U) -> array: 'T array -> 'T (requires comparison)
val s: string
property System.String.Length: int with get
Throws System.ArgumentException.

Array.Parallel.partition predicate array

Full Usage: Array.Parallel.partition predicate array

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    array : 'T array - The input array.

Returns: 'T array * 'T array The two arrays of results.

Split the collection into two collections, containing the elements for which the given predicate returns "true" and "false" respectively

Performs the operation in parallel using Parallel.For. The order in which the given function is applied to indices is not specified.

predicate : 'T -> bool

The function to test the input elements.

array : 'T array

The input array.

Returns: 'T array * 'T array

The two arrays of results.

ArgumentNullException Thrown when the input array is null.
Example

 let inputs = [| 1; 2; 3; 4 |]

 inputs |> Array.Parallel.partition (fun x -> x % 2 = 0)
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|]).

Array.Parallel.reduce reduction array

Full Usage: Array.Parallel.reduce reduction array

Parameters:
    reduction : 'T -> 'T -> 'T - The function to reduce a pair of elements to a single element.
    array : 'T array - The input array.

Returns: 'T Result of the reductions.
Modifiers: inline
Type parameters: 'T

Applies a function to each element of the array in parallel, threading an accumulator argument through the computation for each thread involved in the computation. After processing entire input, results from all threads are reduced together. Raises ArgumentException if the array is empty.

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.

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

The function to reduce a pair of elements to a single element.

array : 'T array

The input array.

Returns: 'T

Result of the reductions.

ArgumentNullException Thrown when the input array is null.
ArgumentException Thrown when the input array is empty.
Example

 let inputs = [| 1; 3; 4; 2 |]

 inputs |> Array.Parallel.reduce (fun a b -> a + b)
val inputs: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val reduce: reduction: ('T -> 'T -> 'T) -> array: 'T array -> 'T
val a: int
val b: int
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.

Array.Parallel.reduceBy projection reduction array

Full Usage: Array.Parallel.reduceBy projection reduction array

Parameters:
    projection : '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 array - The input array.

Returns: 'U The final result of the reductions.

Applies a projection function to each element of the array in parallel, reducing elements in each thread with a dedicated 'reduction' function. After processing entire input, results from all threads are reduced together. Raises ArgumentException if the array is empty.

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)

projection : '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 array

The input array.

Returns: 'U

The final result of the reductions.

ArgumentNullException Thrown when the input array is null.
ArgumentException Thrown when the input array is empty.
Example

 let inputs = [| "1"; "3"; "4"; "2" |]

 inputs |> Array.Parallel.reduceBy  (fun x -> int x) (+)
val inputs: string array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val reduceBy: projection: ('T -> 'U) -> reduction: ('U -> 'U -> 'U) -> array: 'T array -> 'U
val x: string
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int
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.

Array.Parallel.sort array

Full Usage: Array.Parallel.sort array

Parameters:
    array : 'T array - The input array.

Returns: 'T array 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.

array : 'T array

The input array.

Returns: 'T array

The sorted array.

ArgumentNullException Thrown when the input array is null.
Example

 let input = [| 8; 4; 3; 1; 6; 1 |]

 Array.Parallel.sort input
val input: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val sort: array: 'T array -> 'T array (requires comparison)
Evaluates to [| 1; 1 3; 4; 6; 8 |].

Array.Parallel.sortBy projection array

Full Usage: Array.Parallel.sortBy projection array

Parameters:
    projection : 'T -> 'Key - The function to transform array elements into the type that is compared.
    array : 'T array - The input array.

Returns: 'T array 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.

projection : 'T -> 'Key

The function to transform array elements into the type that is compared.

array : 'T array

The input array.

Returns: 'T array

The sorted array.

ArgumentNullException Thrown when the input array is null.
Example

 let input = [| "a"; "bbb"; "cccc"; "dd" |]

 input |> Array.Parallel.sortBy (fun s -> s.Length)
val input: string array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val sortBy: projection: ('T -> 'Key) -> array: 'T array -> 'T array (requires comparison)
val s: string
property System.String.Length: int with get
Evaluates to [|"a"; "dd"; "bbb"; "cccc"|].

Array.Parallel.sortByDescending projection array

Full Usage: Array.Parallel.sortByDescending projection array

Parameters:
    projection : 'T -> 'Key - The function to transform array elements into the type that is compared.
    array : 'T array - The input array.

Returns: 'T array 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.

projection : 'T -> 'Key

The function to transform array elements into the type that is compared.

array : 'T array

The input array.

Returns: 'T array

The sorted array.

Example

 let input = [| "a"; "bbb"; "cccc"; "dd" |]

 input |> Array.Parallel.sortByDescending (fun s -> s.Length)
val input: string array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val sortByDescending: projection: ('T -> 'Key) -> array: 'T array -> 'T array (requires comparison)
val s: string
property System.String.Length: int with get
Evaluates to [|"cccc"; "bbb"; "dd"; "a"|].

Array.Parallel.sortDescending array

Full Usage: Array.Parallel.sortDescending array

Parameters:
    array : 'T array - The input array.

Returns: 'T array 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.

array : 'T array

The input array.

Returns: 'T array

The sorted array.

Example

 let input = [| 8; 4; 3; 1; 6; 1 |]

 input |> Array.Parallel.sortDescending
val input: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val sortDescending: array: 'T array -> 'T array (requires comparison)
Evaluates to [| 8; 6; 4; 3; 1; 1 |].

Array.Parallel.sortInPlace array

Full Usage: Array.Parallel.sortInPlace array

Parameters:
    array : 'T array - 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.

array : 'T array

The input array.

ArgumentNullException Thrown when the input array is null.
Example

 let array = [| 8; 4; 3; 1; 6; 1 |]

 Array.sortInPlace array
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 |].

Array.Parallel.sortInPlaceBy projection array

Full Usage: Array.Parallel.sortInPlaceBy projection array

Parameters:
    projection : 'T -> 'Key - The function to transform array elements into the type that is compared.
    array : 'T array - 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.

projection : 'T -> 'Key

The function to transform array elements into the type that is compared.

array : 'T array

The input array.

ArgumentNullException Thrown when the input array is null.
Example

 let array = [| "a"; "bbb"; "cccc"; "dd" |]

 array |> Array.Parallel.sortInPlaceBy (fun s -> s.Length)
Multiple items
val array: string array

--------------------
type 'T array = 'T array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val sortInPlaceBy: projection: ('T -> 'Key) -> array: 'T array -> unit (requires comparison)
val s: string
property System.String.Length: int with get
After evaluation array contains [|"a"; "dd"; "bbb"; "cccc"|].

Array.Parallel.sortInPlaceWith comparer array

Full Usage: Array.Parallel.sortInPlaceWith comparer array

Parameters:
    comparer : 'T -> 'T -> int - The function to compare pairs of array elements.
    array : 'T array - The input array.

Sorts the elements of an array by mutating the array in-place in parallel, using the given comparison function as the order.

comparer : 'T -> 'T -> int

The function to compare pairs of array elements.

array : 'T array

The input array.

ArgumentNullException Thrown when the input array is null.
Example

The following sorts entries using a comparison function that compares string lengths then index numbers:

 let compareEntries (n1: int, s1: string) (n2: int, s2: string) =
     let c = compare s1.Length s2.Length
     if c <> 0 then c else
     compare n1 n2

 let array = [| (0,"aa"); (1,"bbb"); (2,"cc"); (3,"dd") |]

 array |> Array.Parallel.sortInPlaceWith compareEntries
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
val sortInPlaceWith: comparer: ('T -> 'T -> int) -> array: 'T array -> unit
After evaluation array contains [|(0, "aa"); (2, "cc"); (3, "dd"); (1, "bbb")|].

Array.Parallel.sortWith comparer array

Full Usage: Array.Parallel.sortWith comparer array

Parameters:
    comparer : 'T -> 'T -> int - The function to compare pairs of array elements.
    array : 'T array - The input array.

Returns: 'T array The sorted array.

Sorts the elements of an array in parallel, using the given comparison function as the order, returning a new 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.

comparer : 'T -> 'T -> int

The function to compare pairs of array elements.

array : 'T array

The input array.

Returns: 'T array

The sorted array.

ArgumentNullException Thrown when the input array is null.
Example

Sort an array of pairs using a comparison function that compares string lengths then index numbers:

 let compareEntries (n1: int, s1: string) (n2: int, s2: string) =
     let c = compare s1.Length s2.Length
     if c <> 0 then c else
     compare n1 n2

 let input = [| (0,"aa"); (1,"bbb"); (2,"cc"); (3,"dd") |]

 input |> Array.Parallel.sortWith compareEntries
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
val sortWith: comparer: ('T -> 'T -> int) -> array: 'T array -> 'T array
Evaluates to [|(0, "aa"); (2, "cc"); (3, "dd"); (1, "bbb")|].

Array.Parallel.sum array

Full Usage: Array.Parallel.sum array

Parameters:
    array : ^T array - The input array.

Returns: ^T The resulting sum.
Modifiers: inline
Type parameters: ^T

Returns the sum of the elements in the array.

array : ^T array

The input array.

Returns: ^T

The resulting sum.

ArgumentNullException Thrown when the input array is null.
Example

 let input = [| 1; 5; 3; 2 |]

 input |> Array.Parallel.sum
val input: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val sum: array: 'T array -> 'T (requires member (+) and member Zero)
Evaluates to 11.

Array.Parallel.sumBy projection array

Full Usage: Array.Parallel.sumBy projection array

Parameters:
    projection : 'T -> ^U - The function to transform the array elements into the type to be summed.
    array : 'T array - The input array.

Returns: ^U The resulting sum.
Modifiers: inline
Type parameters: 'T, ^U

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

projection : 'T -> ^U

The function to transform the array elements into the type to be summed.

array : 'T array

The input array.

Returns: ^U

The resulting sum.

ArgumentNullException Thrown when the input array is null.
Example

 let input = [| "aa"; "bbb"; "cc" |]

 input |> Array.Parallel.sumBy (fun s -> s.Length)
val input: string array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val sumBy: projection: ('T -> 'U) -> array: 'T array -> 'U (requires member (+) and member Zero)
val s: string
property System.String.Length: int with get
Evaluates to 7.

Array.Parallel.tryFind predicate array

Full Usage: Array.Parallel.tryFind predicate array

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    array : 'T array - The input array.

Returns: 'T option The first element that satisfies the predicate, or None.

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

predicate : 'T -> bool

The function to test the input elements.

array : 'T array

The input array.

Returns: 'T option

The first element that satisfies the predicate, or None.

ArgumentNullException Thrown when the input array is null.
Example

Try to find the first even number:

 let inputs = [| 1; 2; 3 |]

 inputs |> Array.Parallel.tryFind (fun elm -> elm % 2 = 0)
val inputs: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val tryFind: predicate: ('T -> bool) -> array: 'T array -> 'T option
val elm: int
Evaluates to Some 2.

Example

Try to find the first even number:

 let inputs = [| 1; 5; 3 |]

 inputs |> Array.Parallel.tryFind (fun elm -> elm % 2 = 0)
val inputs: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val tryFind: predicate: ('T -> bool) -> array: 'T array -> 'T option
val elm: int
Evaluates to None

Array.Parallel.tryFindIndex predicate array

Full Usage: Array.Parallel.tryFindIndex predicate array

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    array : 'T array - The input array.

Returns: int option The index of the first element that satisfies the predicate, or None.

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

predicate : 'T -> bool

The function to test the input elements.

array : 'T array

The input array.

Returns: int option

The index of the first element that satisfies the predicate, or None.

ArgumentNullException Thrown when the input array is null.
Example

Try to find the index of the first even number:

 let inputs = [| 1; 2; 3; 4; 5 |]

 inputs |> Array.Parallel.tryFindIndex (fun elm -> elm % 2 = 0)
val inputs: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val tryFindIndex: predicate: ('T -> bool) -> array: 'T array -> int option
val elm: int
Evaluates to Some 1

Example

Try to find the index of the first even number:

 let inputs = [| 1; 3; 5; 7 |]

 inputs |> Array.Parallel.tryFindIndex (fun elm -> elm % 2 = 0)
val inputs: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val tryFindIndex: predicate: ('T -> bool) -> array: 'T array -> int option
val elm: int
Evaluates to None

Array.Parallel.tryPick chooser array

Full Usage: Array.Parallel.tryPick chooser array

Parameters:
    chooser : 'T -> 'U option - The function to transform the array elements into options.
    array : 'T array - The input array.

Returns: 'U option The first transformed element that is Some(x).

Applies the given function to successive elements, returning the first result where the function returns Some(x) for some x. If the function never returns Some(x) then None is returned.

chooser : 'T -> 'U option

The function to transform the array elements into options.

array : 'T array

The input array.

Returns: 'U option

The first transformed element that is Some(x).

ArgumentNullException Thrown when the input array is null.
Example

 let input = [| 1; 2; 3 |]

 input |> Array.Parallel.tryPick (fun n -> if n % 2 = 0 then Some (string n) else None)
val input: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val tryPick: chooser: ('T -> 'U option) -> array: 'T array -> 'U option
val n: int
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

 let input = [| 1; 2; 3 |]

 input |> Array.Parallel.tryPick (fun n -> if n > 3 = 0 then Some (string n) else None)
val input: int array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val tryPick: chooser: ('T -> 'U option) -> array: 'T array -> 'U option
val n: int
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.

Array.Parallel.zip array1 array2

Full Usage: Array.Parallel.zip array1 array2

Parameters:
    array1 : 'T1 array - The first input array.
    array2 : 'T2 array - The second input array.

Returns: ('T1 * 'T2) array The array of tupled elements.

Combines the two arrays into an array of pairs. The two arrays must have equal lengths, otherwise an ArgumentException is raised.

array1 : 'T1 array

The first input array.

array2 : 'T2 array

The second input array.

Returns: ('T1 * 'T2) array

The array of tupled elements.

ArgumentNullException Thrown when either of the input arrays is null.
ArgumentException Thrown when the input arrays differ in length.
Example

 let numbers = [|1; 2|]
 let names = [|"one"; "two"|]

 Array.Parallel.zip numbers names
val numbers: int array
val names: string array
module Array from Microsoft.FSharp.Collections
module Parallel from Microsoft.FSharp.Collections.ArrayModule
val zip: array1: 'T1 array -> array2: 'T2 array -> ('T1 * 'T2) array
Evaluates to [| (1, "one"); (2, "two") |].

Type something to start searching.