[Home] Module Microsoft.FSharp.Collections.List


Basic operations on lists.

Values

ValueDescription
val append : 'a list -> 'a list -> 'a list
Return a new list that contains the elements of the first list followed by elements of the second
val average : overloaded
Return the average of the elements in the list
val average_by : overloaded
Return the average of the elements generated by applying the function to each element of the list
val choose : ('a -> 'b option) -> 'a list -> 'b list
Apply the given function to each element of the list. Return the list comprised of the results x for each element where the function returns Some(x)
[<OCamlCompatibilityAttribute
  ("Consider using List.zip instead, or enable OCaml compatibility and reference FSharp.PowerPack.dll")>]
val combine : 'a list -> 'b list -> ('a * 'b) list
A synonym for List.zip
val concat : seq<'a list> -> 'a list
Return a new list that contains the elements of each the lists in order
[<GeneralizableValueAttribute ()>]
val empty<'a> : 'a list
Return an empty list of the given type
val exists : ('a -> bool) -> 'a list -> bool
Test if any element of the collection satisfies the given predicate. If the elements are i0...iN then computes p i0 or ... or p iN.
val exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
Test if all corresponding elements of the collection satisfy the given predicate pairwise. The predicate is applied to matching elements in the two lists up to the lesser of the two lengths of the lists. If any application returns true then the overall result is true. Otherwise, if one list is longer than the other then the ArgumentException exception is raised. Otherwise, false is returned.
val filter : ('a -> bool) -> 'a list -> 'a list
Return a new collection containing only the elements of the collection for which the given predicate returns "true"
val find : ('a -> bool) -> 'a list -> 'a
Return the first element for which the given function returns true. Raise KeyNotFoundException if no such element exists.
[<OCamlCompatibilityAttribute
  ("Consider using List.filter instead, or enable OCaml compatibility and reference FSharp.PowerPack.dll")>]
val find_all : ('a -> bool) -> 'a list -> 'a list
Return a list containing all the elements for which the given function returns "true". Same as "filter"
val find_index : ('a -> bool) -> 'a list -> int
Return the index of the first element in the list that satisfies the given predicate. Raise KeyNotFoundException if no such element exists.
val find_indexi : (int -> 'a -> bool) -> 'a list -> int
Return the index of the first element in the list that satisfies the given predicate. Raise KeyNotFoundException if no such element exists.
val first : ('a -> 'b option) -> 'a list -> 'b option
Apply the given function to successive elements, returning the first result where function returns Some(x) for some x.
[<OCamlCompatibilityAttribute
  ("Consider using List.concat instead, or enable OCaml compatibility and reference FSharp.PowerPack.dll")>]
val flatten : seq<'a list> -> 'a list
Return a new list that contains the elements of each the lists in order. Same as concat.
val fold_left : ('state -> 'a -> 'state) -> 'state -> 'a list -> 'state
Apply a function to each element of the collection, threading an accumulator argument through the computation. Take the second argument, and apply the function to it and the first element of the list. Then feed this result into the function along with the second element and so on. Return the final result. If the elements are i0...iN then computes f (... (f s i0) i1 ...) iN
val fold_left2 :
  ('state -> 'a -> 'b -> 'state) -> 'state -> 'a list -> 'b list -> 'state
Apply a function to corresponding elements of two collections, threading an accumulator argument through the computation. The collections must have identical sizes. If the elements are i0...iN and "j0...jN" then computes "f (... (f s i0 j0)...) iN jN".
val fold_right : ('a -> 'state -> 'state) -> 'a list -> 'state -> '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 i0 (...(f iN s)).
val fold_right2 :
  ('a -> 'b -> 'state -> 'state) -> 'a list -> 'b list -> 'state -> 'state
Apply a function to corresponding elements of two collections, threading an accumulator argument through the computation. The collections must have identical sizes. If the elements are i0...iN and "j0...jN" then computes "f i0 j0 (...(f iN jN s))".
val for_all : ('a -> bool) -> 'a list -> bool
Test if all elements of the collection satisfy the given predicate. If the elements are i0...iN then computes p i0 && ... && p iN.
val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
Test if all corresponding elements of the collection satisfy the given predicate pairwise. The predicate is applied to matching elements in the two lists up to the lesser of the two lengths of the lists. If any application returns false then the overall result is false. Otherwise, if one list is longer than the other then the ArgumentException exception is raised. Otherwise, true is returned.
val hd : 'a list -> 'a
Return the first element of the list. Raise (Invalid_argument "hd") if undefined.
val init : int -> (int -> 'a) -> 'a list
Create a list by calling the given generator on each index
val is_empty : 'a list -> bool
Return true if the list contains no elements, false otherwise
val iter : ('a -> unit) -> 'a list -> unit
Apply the given function to each element of the collection.
val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
Apply the given function to two collections simultaneously. The collections must have identical size.
val iteri : (int -> 'a -> unit) -> 'a list -> unit
Apply the given function to each element of the collection. The integer passed to the function indicates the index of element.
val iteri2 : (int -> 'a -> 'b -> unit) -> 'a list -> 'b list -> unit
Apply the given function to two collections simultaneously. The collections must have identical size. The integer passed to the function indicates the index of element.
val length : 'a list -> int
Return the length of the list
val map : ('a -> 'b) -> 'a list -> 'b list
Build a new collection whose elements are the results of applying the given function to each of the elements of the collection.
val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
Build a new collection whose elements are the results of applying the given function to the corresponding elements of the two collections pairwise.
val map3 : ('a -> 'b -> 'c -> 'd) -> 'a list -> 'b list -> 'c list -> 'd list
Build a new collection whose elements are the results of applying the given function to the corresponding elements of the three collections simultaneously.
val map_concat : ('a -> 'b list) -> 'a list -> 'b list
For each element of the list, apply the given function. Concatenate all the results and return the combined list.
val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
Build a new collection whose elements are the results of applying the given function to each of the elements of the collection. The integer index passed to the function indicates the index (from 0) of element being transformed.
val mapi2 : (int -> 'a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
Like mapi, but mapping corresponding elements from two lists of equal length.
val max : 'a list -> 'a
Return the greatest of all elements of the list, compared via Operators.max
val max_by : ('a -> 'b) -> 'a list -> 'a
Return the greatest of all elements of the array, compared via Operators.max on the function result
val min : 'a list -> 'a
Return the lowest of all elements of the list, compared via Operators.min
val min_by : ('a -> 'b) -> 'a list -> 'a
Return the lowest of all elements of the array, compared via Operators.min on the function result
val nth : 'a list -> int -> 'a
Index into the list. The first element has index 0.
val of_array : 'a array -> 'a list
Build a collection from the given array
val of_seq : seq<'a> -> 'a list
Build a new collection from the given enumerable object
val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
Split the collection into two collections, containing the elements for which the given predicate returns true and false respectively
val permute : (int -> int) -> 'a list -> 'a list
Returns a list with all elements permuted according to the specified permutation
val reduce_left : ('a -> 'a -> 'a) -> 'a list -> 'a
Apply a function to each element of the collection, threading an accumulator argument through the computation. Apply the function to the first two elements of the list. Then feed this result into the function along with the third element and so on. Return the final result. If the elements are i0...iN then computes "f (... (f i0 i1) i2 ...) iN" Raises ArgumentException if the list has no elements.
val reduce_right : ('a -> 'a -> 'a) -> 'a list -> 'a
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 i0 (...(f iN-1 iN))". Raises ArgumentException if the list has no elements.
val rev : 'a list -> 'a list
Return a new list with the elements in reverse order
val scan_left : ('state -> 'a -> 'state) -> 'state -> 'a list -> 'state list
Apply a function to each element of the collection, threading an accumulator argument through the computation. Take the second argument, and apply the function to it and the first element of the list. Then feed this result into the function along with the second element and so on. Return the list of intermediate results and the final result.
val scan_right : ('a -> 'state -> 'state) -> 'a list -> 'state -> 'state list
Like fold_right, but return both the intermediary and final results
val sort : ('a -> 'a -> int) -> 'a list -> 'a list
Sort the given list using the given comparison function
val sort_by : ('a -> 'b) -> 'a list -> 'a list
Sort the given list using the given comparison function
[<OCamlCompatibilityAttribute
  ("Consider using List.unzip instead, or enable OCaml compatibility and reference FSharp.PowerPack.dll")>]
val split : ('a * 'b) list -> 'a list * 'b list
A synonym for List.unzip
[<OCamlCompatibilityAttribute
  ("Consider using List.sort instead, or enable OCaml compatibility and reference FSharp.PowerPack.dll")>]
val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list
Sort the given list using the given comparison function, preserving order for equal elements.
val sum : overloaded
Return the sum of the elements in the list
val sum_by : overloaded
Return the sum of the results generated by applying the function to each element of the list.
val tl : 'a list -> 'a list
Return the tail of the list. Raise (Invalid_argument "tl") if undefined.
val to_array : 'a list -> 'a array
Build an array from the given collection
val to_seq : 'a list -> seq<'a>
Return a view of the collection as an enumerable object
val tryfind : ('a -> bool) -> 'a list -> '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 list -> int option
Return the index of the first element in the list that satisfies the given predicate. Return None if no such element exists.
val tryfind_indexi : (int -> 'a -> bool) -> 'a list -> int option
Return the index of the first element in the list that satisfies the given predicate. Return None if no such element exists.
val unzip : ('a * 'b) list -> 'a list * 'b list
Split a list of pairs into two lists
val unzip3 : ('a * 'b * 'c) list -> 'a list * 'b list * 'c list
Split a list of triples into three lists
val zip : 'a list -> 'b list -> ('a * 'b) list
Combine the two lists into a list of pairs. The two lists must have equal lengths.
val zip3 : 'a list -> 'b list -> 'c list -> ('a * 'b * 'c) list
Combine the three lists into a list of triples. The lists must have equal lengths.

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