[Home] Module Microsoft.FSharp.Collections.Array


Basic operations on arrays

Values

ValueDescription
val append : 'a [] -> 'a [] -> 'a []
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
val average_by : overloaded
Return the average of the elements generated by applying the function to each element of the array
val blit : 'a [] -> int -> 'a [] -> int -> int -> unit
Read a range of elements from the first array and write them into the second.
val choose : ('a -> 'b option) -> 'a [] -> 'b []
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)
[<OCamlCompatibilityAttribute
  ("Consider using Array.zip instead, or enable OCaml compatibility and reference FSharp.PowerPack.dll")>]
val combine : 'a [] -> 'b [] -> ('a * 'b) array
Combine the two arrays into an array of pairs. The two arrays must have equal lengths.
val concat : seq<'a []> -> 'a []
Build a new array that contains the elements of each of the given sequence of arrays
val copy : 'a [] -> 'a []
Build a new array that contains the elements of the given array
val create : int -> 'a -> 'a []
Create an array whose elements are all initially the given value.
[<GeneralizableValueAttribute ()>]
val empty<'a> : 'a []
Return an empty array of the given type
val exists : ('a -> bool) -> 'a [] -> bool
Test if any element of the array satisfies the given predicate. If the elements are i0...iN then computes "p i0 or ... or p iN".
val exists2 : ('a -> 'b -> bool) -> 'a [] -> 'b [] -> bool
Test elements of the two arrays pairwise to see if any pair of element satisfies the given predicate. Raise ArgumentException if the arrays have different lengths.
val fill : 'a [] -> int -> int -> 'a -> unit
Fill a range of an array with the given element
val filter : ('a -> bool) -> 'a [] -> 'a []
Return a new collection containing only the elements of the collection for which the given predicate returns "true"
val find : ('a -> bool) -> 'a [] -> 'a
Return the first element for which the given function returns 'true'. Raise KeyNotFoundException if no such element exists.
val find_index : ('a -> bool) -> 'a [] -> 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 find_indexi : (int -> 'a -> bool) -> 'a [] -> 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 first : ('a -> 'b option) -> 'a [] -> 'b 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 fold_left : ('state -> 'b -> 'state) -> 'state -> 'b [] -> 'state
Apply a function to each element of the collection, threading an accumulator argument through the computation. If the elements are i0...iN then computes f (... (f s i0)...) iN
val fold_left2 :
  ('state -> 'b1 -> 'b2 -> 'state) -> 'state -> 'b1 [] -> 'b2 [] -> '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.
val fold_right : ('a -> 'state -> 'state) -> 'a [] -> 'state -> 'state
Apply a function to each element of the array, threading an accumulator argument through the computation. If the elements are i0...iN then computes f i0 (...(f iN s))
val fold_right2 :
  ('a1 -> 'a2 -> 'state -> 'state) -> 'a1 [] -> 'a2 [] -> '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.
val for_all : ('a -> bool) -> 'a [] -> bool
Test if all elements of the array satisfy the given predicate. If the elements are i0...iN then computes "p i0 && ... && p iN".
val for_all2 : ('a -> 'b -> bool) -> 'a [] -> 'b [] -> bool
Test elements of the two arrays pairwise to see if all pairs of elements satisfy the given predicate. Raise ArgumentException if the arrays have different lengths.
val get : 'a [] -> int -> 'a
Fetch an element from an array. You can also use the syntax 'arr.[idx]'.
val init : int -> (int -> 'a) -> 'a []
Create an array given the dimension and a generator function to compute the elements.
val is_empty : 'a [] -> bool
Return true if the given array is empty, otherwise false
val iter : ('a -> unit) -> 'a [] -> unit
Apply the given function to each element of the array.
val iter2 : ('a -> 'b -> unit) -> 'a [] -> 'b [] -> 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 -> 'a -> unit) -> 'a [] -> 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 -> 'a -> 'b -> unit) -> 'a [] -> 'b [] -> 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 : 'a [] -> int
Return the length of an array. You can also use property arr.Length.
[<OCamlCompatibilityAttribute
  ("Consider using Array.create instead, or enable OCaml compatibility and reference FSharp.PowerPack.dll")>]
val make : int -> 'a -> 'a array
Create an array whose elements are all initially the given value
val map : ('a -> 'b) -> 'a [] -> 'b []
Build a new array whose elements are the results of applying the given function to each of the elements of the array.
val map2 : ('a -> 'b -> 'c) -> 'a [] -> 'b [] -> 'c 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 -> 'a -> 'b) -> 'a [] -> 'b []
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 -> 'a -> 'b -> 'c) -> 'a [] -> 'b [] -> 'c 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 : 'a [] -> 'a
Return the greatest of all elements of the array, compared via Operators.max on the function result
val max_by : ('a -> 'b) -> 'a [] -> 'a
Return the greatest of all elements of the array, compared via Operators.max on the function result
val min : 'a [] -> 'a
Return the lowest of all elements of the array, compared via Operators.min
val min_by : ('a -> 'b) -> 'a [] -> 'a
Return the lowest of all elements of the array, compared via Operators.min on the function result
val of_list : 'a list -> 'a []
Build an array from the given list
val of_seq : seq<'a> -> 'a []
Build a new array from the given enumerable object
val partition : ('a -> bool) -> 'a [] -> 'a [] * 'a []
Split the collection into two collections, containing the elements for which the given predicate returns "true" and "false" respectively
val permute : (int -> int) -> 'a [] -> 'a []
Returns an array with all elements permuted according to the specified permutation
val reduce_left : ('a -> 'a -> 'a) -> 'a [] -> 'a
Apply a function to each element of the array, threading an accumulator argument through the computation. If the elements are i0...iN then computes f (... (f i0 i1)...) iN Raises ArgumentException if the array has size zero.
val reduce_right : ('a -> 'a -> 'a) -> 'a [] -> 'a
Apply a function to each element of the array, threading an accumulator argument through the computation. If the elements are i0...iN then computes f i0 (...(f iN-1 iN)) Raises ArgumentException if the array has size zero.
val rev : 'a [] -> 'a []
Return a new array with the elements in reverse order
val scan_left : ('state -> 'a -> 'state) -> 'state -> 'a [] -> 'state []
Like fold_left, but return the intermediary and final results
val scan_right : ('a -> 'state -> 'state) -> 'a [] -> 'state -> 'state []
Like fold_right, but return both the intermediary and final results
val set : 'a [] -> int -> 'a -> unit
Set the value of an element in an array. You can also use the syntax 'arr.[idx] <- e'.
val sort : ('a -> 'a -> int) -> 'a [] -> unit
Sort the elements of an array, using the given comparison function as the order
val sort_by : ('a -> 'b) -> 'a [] -> unit
Sort the elements of an array, using the given projection for the keys. Keys are compared using Operators.compare.
[<OCamlCompatibilityAttribute
  ("Consider using Array.unzip instead, or enable OCaml compatibility and reference FSharp.PowerPack.dll")>]
val split : ('a * 'b) array -> 'a [] * 'b []
Split an array of pairs into two arrays
val sub : 'a [] -> int -> int -> 'a []
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 sum_by : overloaded
Return the sum of the results generated by applying the function to each element of the array.
val to_list : 'a [] -> 'a list
Build a list from the given array
val to_seq : 'a [] -> seq<'a>
Return a view of the array as an enumerable object
val tryfind : ('a -> bool) -> 'a [] -> 'a option
Return the first element for which the given function returns true. Return None if no such element exists.
val tryfind_index : ('a -> bool) -> 'a [] -> int option
Return the index of the first element in the array that satisfies the given predicate.
val tryfind_indexi : (int -> 'a -> bool) -> 'a [] -> int option
Return the index of the first element in the array that satisfies the given predicate.
val unzip : ('a * 'b) [] -> 'a [] * 'b []
Split an array of pairs into two arrays
val unzip3 : ('a * 'b * 'c) array -> 'a [] * 'b [] * 'c []
Split an array of triples into three arrays
val zero_create : int -> 'a []
Create an array where the entries are initially the default value Unchecked.defaultof<'a>.
val zip : 'a [] -> 'b [] -> ('a * 'b) array
Combine the two arrays into an array of pairs. The two arrays must have equal lengths, otherwise an ArgumentException is raised..
val zip3 : 'a [] -> 'b [] -> 'c [] -> ('a * 'b * 'c) 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.0, generated using F# Programming Language version 1.9.6.0