FSharpPlus


Array Module

Additional operations on Array

Functions and values

Function or value Description

Array.apply f x

Full Usage: Array.apply f x

Parameters:
    f : ('a -> 'b)[] - The array of functions.
    x : 'a[] - The array of values.

Returns: 'b[] A concatenated array of the resulting arrays from applying each function to each value

Applies an array of functions to an array of values and concatenates them.

f : ('a -> 'b)[]

The array of functions.

x : 'a[]

The array of values.

Returns: 'b[]

A concatenated array of the resulting arrays from applying each function to each value

Example

 > Array.apply [|double; triple|] [|1; 2; 3|];;  
 val it : int [] = [|2; 4; 6; 3; 6; 9|]
module Array from Microsoft.FSharp.Collections
Multiple items
val double: value: 'T -> double (requires member op_Explicit)

--------------------
type double = System.Double

--------------------
type double<'Measure> = float<'Measure>
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

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

--------------------
type int<'Measure> = int

Array.choosei mapping source

Full Usage: Array.choosei mapping source

Parameters:
    mapping : int -> 'b -> 'c option - The mapping function, taking index and element as parameters.
    source : 'b[] - The input array.

Returns: 'c[] Array with values x for each Array value where the function returns Some(x).

Same as choose but with access to the index.

mapping : int -> 'b -> 'c option

The mapping function, taking index and element as parameters.

source : 'b[]

The input array.

Returns: 'c[]

Array with values x for each Array value where the function returns Some(x).

Array.findSliceIndex slice source

Full Usage: Array.findSliceIndex slice source

Parameters:
    slice : 'b[]
    source : 'b[]

Returns: int The index of the slice. The index of the slice or None.

Returns the index of the first occurrence of the specified slice in the source. Returns the index of the first occurrence of the specified slice in the source. Note: this is unsafe and will throw ArgumentException when the specified slice is not found.

slice : 'b[]
source : 'b[]
Returns: int

The index of the slice. The index of the slice or None.

ArgumentException Thrown when the slice was not found in the sequence.

Array.intercalate separator source

Full Usage: Array.intercalate separator source

Parameters:
    separator : 'T[]
    source : seq<'T[]>

Returns: 'T[]

Concatenates all elements, using the specified separator between each element.

separator : 'T[]
source : seq<'T[]>
Returns: 'T[]

Array.intersperse element source

Full Usage: Array.intersperse element source

Parameters:
    element : 'T
    source : 'T[]

Returns: 'T[]

Inserts a separator element between each element in the source array.

element : 'T
source : 'T[]
Returns: 'T[]

Array.lift2 f x y

Full Usage: Array.lift2 f x y

Parameters:
    f : 'd -> 'e -> 'f
    x : 'd[]
    y : 'e[]

Returns: 'f[]

Combines all values from the first array with the second, using the supplied mapping function.

f : 'd -> 'e -> 'f
x : 'd[]
y : 'e[]
Returns: 'f[]

Array.lift3 mapping list1 list2 list3

Full Usage: Array.lift3 mapping list1 list2 list3

Parameters:
    mapping : 'e -> 'f -> 'g -> 'h - Mapping function taking three element combination as input.
    list1 : 'e[] - First array.
    list2 : 'f[] - Second array.
    list3 : 'g[] - Third array.

Returns: 'h[] Array with values returned from mapping function.

Combines all values from three arrays and calls a mapping function on this combination.

mapping : 'e -> 'f -> 'g -> 'h

Mapping function taking three element combination as input.

list1 : 'e[]

First array.

list2 : 'f[]

Second array.

list3 : 'g[]

Third array.

Returns: 'h[]

Array with values returned from mapping function.

Array.map2Shortest f a1 a2

Full Usage: Array.map2Shortest f a1 a2

Parameters:
    f : 'T -> 'U -> 'a
    a1 : 'T[]
    a2 : 'U[]

Returns: 'a[]

Safely build a new array whose elements are the results of applying the given function to each of the elements of the two arrays pairwise.

f : 'T -> 'U -> 'a
a1 : 'T[]
a2 : 'U[]
Returns: 'a[]

Array.partitionMap mapper source

Full Usage: Array.partitionMap mapper source

Parameters:
    mapper : 'T -> Choice<'T1, 'T2>
    source : 'T array

Returns: 'T1[] * 'T2[] A tuple with both resulting arrays.

Creates two arrays by applying the mapper function to each element in the array and classifies the transformed values depending on whether they were wrapped with Choice1Of2 or Choice2Of2.

mapper : 'T -> Choice<'T1, 'T2>
source : 'T array
Returns: 'T1[] * 'T2[]

A tuple with both resulting arrays.

Array.replace oldValue newValue source

Full Usage: Array.replace oldValue newValue source

Parameters:
    oldValue : 'T[]
    newValue : 'T[]
    source : 'T[]

Returns: 'T[]

Replaces a subsequence of the source array with the given replacement array.

oldValue : 'T[]
newValue : 'T[]
source : 'T[]
Returns: 'T[]

Array.split separators source

Full Usage: Array.split separators source

Parameters:
    separators : seq<'a[]>
    source : 'a[]

Returns: seq<'a[]>

Creates a sequence of arrays by splitting the source array on any of the given separators.

separators : seq<'a[]>
source : 'a[]
Returns: seq<'a[]>

Array.tryFindSliceIndex slice source

Full Usage: Array.tryFindSliceIndex slice source

Parameters:
    slice : 'b[]
    source : 'b[]

Returns: int option The index of the slice or None.

Returns the index of the first occurrence of the specified slice in the source. Returns None if not found.

slice : 'b[]
source : 'b[]
Returns: int option

The index of the slice or None.

Array.zipShortest a1 a2

Full Usage: Array.zipShortest a1 a2

Parameters:
    a1 : 'T1 array - First input array.
    a2 : 'T2 array - Second input array.

Returns: ('T1 * 'T2)[] Array with corresponding pairs of input arrays.

Zip safely two arrays. If one array is shorter, excess elements are discarded from the right end of the longer array.

a1 : 'T1 array

First input array.

a2 : 'T2 array

Second input array.

Returns: ('T1 * 'T2)[]

Array with corresponding pairs of input arrays.