[Home] Module Microsoft.FSharp.Collections.Array


Basic operations on arrays

Values

ValueDescription
val append : 'T array -> 'T array -> 'T array
Build a new array that contains the elements of the first array followed by the elements of the second array
val average : overloaded
Return the average of the elements in the array. If the array is empty an ArgumentException is thrown.
val averageBy : overloaded
Return the average of the elements generated by applying the function to each element of the array. If the array is empty an ArgumentException is thrown.
val blit : 'T array -> int -> 'T array -> int -> int -> unit
Read a range of elements from the first array and write them into the second.
val choose : ('T -> 'U option) -> 'T array -> 'U array
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)
val collect : ('T -> 'U array) -> 'T array -> 'U array
For each element of the array, apply the given function. Concatenate all the results and return the combined array.
[<OCamlCompatibilityAttribute
  ("This F# library function has been renamed. Use 'zip' instead")>]
val combine : 'T1 array -> 'T2 array -> ('T1 * 'T2) array
val concat : seq<'T array> -> 'T array
Build a new array that contains the elements of each of the given sequence of arrays
val copy : 'T array -> 'T array
Build a new array that contains the elements of the given array
val create : int -> 'T -> 'T array
Create an array whose elements are all initially the given value.
[<GeneralizableValueAttribute ()>]
val empty<'T> : 'T array
Return an empty array of the given type
val exists : ('T -> bool) -> 'T array -> bool
Test if any element of the array satisfies the given predicate. The predicate is applied to the elements of the input array. If any application returns true then the overall result is true and no further elements are tested. Otherwise, false is returned.
val exists2 : ('T1 -> 'T2 -> bool) -> 'T1 array -> 'T2 array -> bool
Test if any pair of corresponding elements of the arrays satisfies the given predicate. The predicate is applied to matching elements in the two collections up to the lesser of the two lengths of the collections. If any application returns true then the overall result is true and no further elements are tested. Otherwise, if one collections is longer than the other then the ArgumentException exception is raised. Otherwise, false is returned.
val fill : 'T array -> int -> int -> 'T -> unit
Fill a range of elements of the array with the given value.
val filter : ('T -> bool) -> 'T array -> 'T array
Return a new collection containing only the elements of the collection for which the given predicate returns "true"
val find : ('T -> bool) -> 'T array -> 'T
Return the first element for which the given function returns 'true'. Raise KeyNotFoundException if no such element exists.
val findIndex : ('T -> bool) -> 'T array -> int
Return the index of the first element in the array that satisfies the given predicate. Raise KeyNotFoundException if none of the elements satisy the predicate.
val fold : ('State -> 'T -> 'State) -> 'State -> 'T array -> 'State
Apply a function to each element of the collection, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN then computes f (... (f s i0)...) iN
val fold2 :
  ('State -> 'T1 -> 'T2 -> 'State) -> 'State -> 'T1 array -> 'T2 array -> 'State
Apply a function to pairs of elements drawn from the two collections, left-to-right, threading an accumulator argument through the computation. The two input arrays must have the same lengths, otherwise an ArgumentException is raised.
[<OCamlCompatibilityAttribute
  ("This F# library function has been renamed. Use 'fold' instead")>]
val fold_left : ('State -> 'T -> 'State) -> 'State -> 'T array -> 'State
[<OCamlCompatibilityAttribute
  ("This F# library function has been renamed. Use 'foldBack' instead")>]
val fold_right : ('T -> 'State -> 'State) -> 'T array -> 'State -> 'State
Apply a function to each element of the array, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN then computes f i0 (...(f iN s))
val foldBack : ('T -> 'State -> 'State) -> 'T array -> 'State -> 'State
Apply a function to each element of the array, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN then computes f i0 (...(f iN s))
val foldBack2 :
  ('T1 -> 'T2 -> 'State -> 'State) -> 'T1 array -> 'T2 array -> 'State -> 'State
Apply a function to pairs of elements drawn from the two collections, right-to-left, threading an accumulator argument through the computation. The two input arrays must have the same lengths, otherwise an ArgumentException is raised.
[<OCamlCompatibilityAttribute
  ("This F# library function has been renamed. Use 'forall' instead")>]
val for_all : ('T -> bool) -> 'T array -> bool
val forall : ('T -> bool) -> 'T array -> bool
Test if all elements of the array satisfy the given predicate. The predicate is applied to the elements of the input collection. If any application returns false then the overall result is false and no further elements are tested. Otherwise, true is returned.
val forall2 : ('T1 -> 'T2 -> bool) -> 'T1 array -> 'T2 array -> bool
Test if all corresponding elements of the array satisfy the given predicate pairwise. The predicate is applied to matching elements in the two collections up to the lesser of the two lengths of the collections. If any application returns false then the overall result is false and no further elements are tested. Otherwise, if one collection is longer than the other then the ArgumentException exception is raised. Otherwise, true is returned.
val get : 'T array -> int -> 'T
Get an element from an array
val init : int -> (int -> 'T) -> 'T array
Create an array given the dimension and a generator function to compute the elements.
val isEmpty : 'T array -> bool
Return true if the given array is empty, otherwise false
val iter : ('T -> unit) -> 'T array -> unit
Apply the given function to each element of the array.
val iter2 : ('T1 -> 'T2 -> unit) -> 'T1 array -> 'T2 array -> unit
Apply the given function to pair of elements drawn from matching indices in two arrays. The two arrays must have the same lengths, otherwise an ArgumentException is raised.
val iteri : (int -> 'T -> unit) -> 'T array -> unit
Apply the given function to each element of the array. The integer passed to the function indicates the index of element.
val iteri2 : (int -> 'T1 -> 'T2 -> unit) -> 'T1 array -> 'T2 array -> unit
Apply the given function to pair of elements drawn from matching indices in two arrays, also passing the index of the elements. The two arrays must have the same lengths, otherwise an ArgumentException is raised.
val length : 'T array -> int
Return the length of an array. You can also use property arr.Length.
[<OCamlCompatibilityAttribute
  ("This F# library function has been renamed. Use 'create' instead")>]
val make : int -> 'T -> 'T array
val map : ('T -> 'U) -> 'T array -> 'U array
Build a new array whose elements are the results of applying the given function to each of the elements of the array.
val map2 : ('T1 -> 'T2 -> 'U) -> 'T1 array -> 'T2 array -> 'U array
Build a new collection whose elements are the results of applying the given function to the corresponding elements of the two collections pairwise. The two input arrays must have the same lengths, otherwise an ArgumentException is raised.
val mapi : (int -> 'T -> 'U) -> 'T array -> 'U array
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.
val mapi2 : (int -> 'T1 -> 'T2 -> 'U) -> 'T1 array -> 'T2 array -> 'U array
Build a new collection whose elements are the results of applying the given function to the corresponding elements of the two collections pairwise, also passing the index of the elements. The two input arrays must have the same lengths, otherwise an ArgumentException is raised.
val max : 'T array -> 'T
Return the greatest of all elements of the array, compared via Operators.max on the function result
val maxBy : ('T -> 'U) -> 'T array -> 'T
Return the greatest of all elements of the array, compared via Operators.max on the function result
val min : 'T array -> 'T
Return the lowest of all elements of the array, compared via Operators.min
val minBy : ('T -> 'U) -> 'T array -> 'T
Return the lowest of all elements of the array, compared via Operators.min on the function result
val of_list : 'T list -> 'T array
Build an array from the given list
val of_seq : seq<'T> -> 'T array
Build a new array from the given enumerable object
val partition : ('T -> bool) -> 'T array -> 'T array * 'T array
Split the collection into two collections, containing the elements for which the given predicate returns "true" and "false" respectively
val permute : (int -> int) -> 'T array -> 'T array
Returns an array with all elements permuted according to the specified permutation
val pick : ('T -> 'U option) -> 'T array -> 'U
Apply the given function to successive elements, returning the first result where function returns Some(x) for some x. If the function never returns Some(x) then KeyNotFoundException is raised.
val reduce : ('T -> 'T -> 'T) -> 'T array -> 'T
Apply a function to each element of the array, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN then computes f (... (f i0 i1)...) iN. Raises ArgumentException if the array has size zero.
val reduceBack : ('T -> 'T -> 'T) -> 'T array -> 'T
Apply a function to each element of the array, threading an accumulator argument through the computation. If the input function is f and the elements are i0...iN then computes f i0 (...(f iN-1 iN)). Raises ArgumentException if the array has size zero.
val rev : 'T array -> 'T array
Return a new array with the elements in reverse order
val scan : ('State -> 'T -> 'State) -> 'State -> 'T array -> 'State array
Like fold_left, but return the intermediary and final results
val scanBack : ('T -> 'State -> 'State) -> 'T array -> 'State -> 'State array
Like fold_right, but return both the intermediary and final results
val set : 'T array -> int -> 'T -> unit
Set an element of an array
val sort : 'T array -> 'T array
Sort the elements of an array, returning a new array. Elements are compared using Operators.compare.
val sortBy : ('T -> 'U) -> 'T array -> 'T array
Sort the elements of an array, using the given projection for the keys and returning a new array. Elements are compared using Operators.compare.
val sortInPlace : 'T array -> unit
Sort the elements of an array by mutating the array in-place, using the given comparison function. Elements are compared using Operators.compare.
val sortInPlaceBy : ('T -> 'U) -> 'T array -> unit
Sort the elements of an array by mutating the array in-place, using the given projection for the keys. Elements are compared using Operators.compare.
val sortInPlaceWith : ('T -> 'T -> int) -> 'T array -> unit
Sort the elements of an array by mutating the array in-place, using the given comparison function as the order
val sortWith : ('T -> 'T -> int) -> 'T array -> 'T array
Sort the elements of an array, using the given comparison function as the order, returning a new array
[<OCamlCompatibilityAttribute
  ("This F# library function has been renamed. Use 'unzip' instead")>]
val split : ('T1 * 'T2) array -> 'T1 array * 'T2 array
val sub : 'T array -> int -> int -> 'T array
Build a new array that contains the given subrange specified by starting index and length.
val sum : overloaded
Return the sum of the elements in the array
val sumBy : overloaded
Return the sum of the results generated by applying the function to each element of the array.
val to_list : 'T array -> 'T list
Build a list from the given array
val to_seq : 'T array -> seq<'T>
View the given array as a sequence
val tryFind : ('T -> bool) -> 'T array -> 'T option
Return the first element for which the given function returns true. Return None if no such element exists.
val tryFindIndex : ('T -> bool) -> 'T array -> int option
Return the index of the first element in the array that satisfies the given predicate.
val tryPick : ('T -> 'U option) -> 'T array -> 'U option
Apply the given function to successive elements, returning the first result where function returns Some(x) for some x. If the function never returns Some(x) then None is returned.
val unzip : ('T1 * 'T2) array -> 'T1 array * 'T2 array
Split an array of pairs into two arrays
val unzip3 : ('T1 * 'T2 * 'T3) array -> 'T1 array * 'T2 array * 'T3 array
Split an array of triples into three arrays
val zeroCreate : int -> 'T array
Create an array where the entries are initially the default value Unchecked.defaultof<'T>.
val zip : 'T1 array -> 'T2 array -> ('T1 * 'T2) array
Combine the two arrays into an array of pairs. The two arrays must have equal lengths, otherwise an ArgumentException is raised.
val zip3 : 'T1 array -> 'T2 array -> 'T3 array -> ('T1 * 'T2 * 'T3) array
Combine three arrays into an array of pairs. The three arrays must have equal lengths, otherwise an ArgumentException is raised.

See Also

Microsoft.FSharp.Collections


Documentation for assembly FSharp.Core, version 1.9.6.16, generated using F# Programming Language version 1.9.6.16