[Home] Module Microsoft.FSharp.Collections.List


Basic operations on lists.

Values

ValueDescription
val append : 'T list -> 'T list -> 'T 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. If the list 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 list. If the list is empty an ArgumentException is thrown.
val choose : ('T -> 'U option) -> 'T list -> 'U 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)
val collect : ('T -> 'U list) -> 'T list -> 'U list
For each element of the list, apply the given function. Concatenate all the results and return the combined list.
val concat : seq<'T list> -> 'T list
Return a new list that contains the elements of each the lists in order
[<GeneralizableValueAttribute ()>]
val empty<'T> : 'T list
Return an empty list of the given type
val exists : ('T -> bool) -> 'T list -> bool
Test if any element of the list satisfies the given predicate. The predicate is applied to the elements of the input list. 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 list -> 'T2 list -> bool
Test if any pair of corresponding elements of the lists 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 filter : ('T -> bool) -> 'T list -> 'T list
Return a new collection containing only the elements of the collection for which the given predicate returns "true"
val find : ('T -> bool) -> 'T list -> 'T
Return the first element for which the given function returns true. Raise KeyNotFoundException if no such element exists.
val findIndex : ('T -> bool) -> 'T 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 fold : ('State -> 'T -> 'State) -> 'State -> 'T 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 input function is f and the elements are i0...iN then computes f (... (f s i0) i1 ...) iN
val fold2 :
  ('State -> 'T1 -> 'T2 -> 'State) -> 'State -> 'T1 list -> 'T2 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 input function is f and the elements are i0...iN and j0...jN then computes f (... (f s i0 j0)...) iN jN.
val foldBack : ('T -> 'State -> 'State) -> 'T list -> 'State -> '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 i0 (...(f iN s)).
val foldBack2 :
  ('T1 -> 'T2 -> 'State -> 'State) -> 'T1 list -> 'T2 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 input function is f and the elements are i0...iN and j0...jN then computes f i0 j0 (...(f iN jN s)).
val forall : ('T -> bool) -> 'T list -> bool
Test if all elements of the collection satisfy the given predicate. The predicate is applied to the elements of the input list. 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 list -> 'T2 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 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 hd : 'T list -> 'T
Return the first element of the list. Raise (Invalid_argument "hd") if undefined.
val init : int -> (int -> 'T) -> 'T list
Create a list by calling the given generator on each index
val isEmpty : 'T list -> bool
Return true if the list contains no elements, false otherwise
val iter : ('T -> unit) -> 'T list -> unit
Apply the given function to each element of the collection.
val iter2 : ('T1 -> 'T2 -> unit) -> 'T1 list -> 'T2 list -> unit
Apply the given function to two collections simultaneously. The collections must have identical size.
val iteri : (int -> 'T -> unit) -> 'T 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 -> 'T1 -> 'T2 -> unit) -> 'T1 list -> 'T2 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 : 'T list -> int
Return the length of the list
val map : ('T -> 'U) -> 'T list -> 'U 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 : ('T1 -> 'T2 -> 'U) -> 'T1 list -> 'T2 list -> 'U 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 :
  ('T1 -> 'T2 -> 'T3 -> 'U) -> 'T1 list -> 'T2 list -> 'T3 list -> 'U 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 mapi : (int -> 'T -> 'U) -> 'T list -> 'U 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 -> 'T1 -> 'T2 -> 'U) -> 'T1 list -> 'T2 list -> 'U list
Like mapi, but mapping corresponding elements from two lists of equal length.
val max : 'T list -> 'T
Return the greatest of all elements of the list, compared via Operators.max
val maxBy : ('T -> 'U) -> 'T list -> 'T
Return the greatest of all elements of the array, compared via Operators.max on the function result
val min : 'T list -> 'T
Return the lowest of all elements of the list, compared via Operators.min
val minBy : ('T -> 'U) -> 'T list -> 'T
Return the lowest of all elements of the array, compared via Operators.min on the function result
val nth : 'T list -> int -> 'T
Index into the list. The first element has index 0.
val of_array : 'T array -> 'T list
Build a collection from the given array
val of_seq : seq<'T> -> 'T list
Build a new collection from the given enumerable object
val partition : ('T -> bool) -> 'T list -> 'T list * 'T list
Split the collection into two collections, containing the elements for which the given predicate returns true and false respectively
val permute : (int -> int) -> 'T list -> 'T list
Returns a list with all elements permuted according to the specified permutation
val pick : ('T -> 'U option) -> 'T list -> 'U
Apply the given function to successive elements, returning the first result where function returns Some(x) for some x. If no such element exists then raise System.Collections.Generic.KeyNotFoundException
val reduce : ('T -> 'T -> 'T) -> 'T list -> 'T
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 input function is f and the elements are i0...iN then computes f (... (f i0 i1) i2 ...) iN. Raises ArgumentException if the list has no elements.
val reduceBack : ('T -> 'T -> 'T) -> 'T list -> 'T
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 i0 (...(f iN-1 iN)). Raises ArgumentException if the list has no elements.
val replicate : int -> 'T -> 'T list
Create a list by calling the given generator on each index
val rev : 'T list -> 'T list
Return a new list with the elements in reverse order
val scan : ('State -> 'T -> 'State) -> 'State -> 'T 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 scanBack : ('T -> 'State -> 'State) -> 'T list -> 'State -> 'State list
Like foldBack, but return both the intermediary and final results
val sort : 'T list -> 'T list
Sort the given list using the given comparison function
val sortBy : ('T -> 'U) -> 'T list -> 'T list
Sort the given list using keys given by the given projection. Keys are compared using Operators.compare.
val sortWith : ('T -> 'T -> int) -> 'T list -> 'T list
Sort the given list using the given comparison function
val sum : overloaded
Return the sum of the elements in the list
val sumBy : overloaded
Return the sum of the results generated by applying the function to each element of the list.
val tl : 'T list -> 'T list
Return the tail of the list. Raise (Invalid_argument "tl") if undefined.
val to_array : 'T list -> 'T array
Build an array from the given collection
val to_seq : 'T list -> seq<'T>
Build a new collection from the given enumerable object
val tryFind : ('T -> bool) -> 'T list -> '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 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 tryPick : ('T -> 'U option) -> 'T list -> 'U option
Apply the given function to successive elements, returning Some(x) the first result where function returns Some(x) for some x. If no such element exists then return None
val unzip : ('T1 * 'T2) list -> 'T1 list * 'T2 list
Split a list of pairs into two lists
val unzip3 : ('T1 * 'T2 * 'T3) list -> 'T1 list * 'T2 list * 'T3 list
Split a list of triples into three lists
val zip : 'T1 list -> 'T2 list -> ('T1 * 'T2) list
Combine the two lists into a list of pairs. The two lists must have equal lengths.
val zip3 : 'T1 list -> 'T2 list -> 'T3 list -> ('T1 * 'T2 * 'T3) 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.16, generated using F# Programming Language version 1.9.6.16