FSharp.Core


List Module

Namespace: FSharp.Collections

Assembly: FSharp.Core.dll

Contains operations for working with values of type list.Operations for collections such as lists, arrays, sets, maps and sequences. See also F# Collection Types in the F# Language Guide.

Functions and values

Function or value Description

List.allPairs list1 list2

Full Usage: List.allPairs list1 list2

Parameters:
    list1 : 'T1 list - The first input list.
    list2 : 'T2 list - The second input list.

Returns: ('T1 * 'T2) list The resulting list of pairs.

Returns a new list that contains all pairings of elements from the first and second lists.

list1 : 'T1 list

The first input list.

list2 : 'T2 list

The second input list.

Returns: ('T1 * 'T2) list

The resulting list of pairs.

List.append list1 list2

Full Usage: List.append list1 list2

Parameters:
    list1 : 'T list - The first input list.
    list2 : 'T list - The second input list.

Returns: 'T list The resulting list.

Returns a new list that contains the elements of the first list followed by elements of the second.

list1 : 'T list

The first input list.

list2 : 'T list

The second input list.

Returns: 'T list

The resulting list.

List.average list

Full Usage: List.average list

Parameters:
    list : ^T list - The input list.

Returns: ^T The resulting average.

Returns the average of the elements in the list.

Raises ArgumentException if list is empty.

list : ^T list

The input list.

Returns: ^T

The resulting average.

ArgumentException Thrown when the list is empty.

List.averageBy projection list

Full Usage: List.averageBy projection list

Parameters:
    projection : 'T -> ^U - The function to transform the list elements into the type to be averaged.
    list : 'T list - The input list.

Returns: ^U The resulting average.

Returns the average of the elements generated by applying the function to each element of the list.

Raises ArgumentException if list is empty.

projection : 'T -> ^U

The function to transform the list elements into the type to be averaged.

list : 'T list

The input list.

Returns: ^U

The resulting average.

ArgumentException Thrown when the list is empty.

List.choose chooser list

Full Usage: List.choose chooser list

Parameters:
    chooser : 'T -> 'U option - The function to generate options from the elements.
    list : 'T list - The input list.

Returns: 'U list The list comprising the values selected from the chooser function.

Applies the given function to each element of the list. Returns the list comprised of the results x for each element where the function returns Some(x)

chooser : 'T -> 'U option

The function to generate options from the elements.

list : 'T list

The input list.

Returns: 'U list

The list comprising the values selected from the chooser function.

List.chunkBySize chunkSize list

Full Usage: List.chunkBySize chunkSize list

Parameters:
    chunkSize : int - The maximum size of each chunk.
    list : 'T list - The input list.

Returns: 'T list list The list divided into chunks.

Divides the input list into chunks of size at most chunkSize.

chunkSize : int

The maximum size of each chunk.

list : 'T list

The input list.

Returns: 'T list list

The list divided into chunks.

ArgumentException Thrown when chunkSize is not positive.

List.collect mapping list

Full Usage: List.collect mapping list

Parameters:
    mapping : 'T -> 'U list - The function to transform each input element into a sublist to be concatenated.
    list : 'T list - The input list.

Returns: 'U list The concatenation of the transformed sublists.

For each element of the list, applies the given function. Concatenates all the results and return the combined list.

mapping : 'T -> 'U list

The function to transform each input element into a sublist to be concatenated.

list : 'T list

The input list.

Returns: 'U list

The concatenation of the transformed sublists.

List.compareWith comparer list1 list2

Full Usage: List.compareWith comparer list1 list2

Parameters:
    comparer : 'T -> 'T -> int - A function that takes an element from each list and returns an int. If it evaluates to a non-zero value iteration is stopped and that value is returned.
    list1 : 'T list - The first input list.
    list2 : 'T list - The second input list.

Returns: int Returns the first non-zero result from the comparison function. If the first list has a larger element, the return value is always positive. If the second list has a larger element, the return value is always negative. When the elements are equal in the two lists, 1 is returned if the first list is longer, 0 is returned if they are equal in length, and -1 is returned when the second list is longer.

Compares two lists using the given comparison function, element by element.

comparer : 'T -> 'T -> int

A function that takes an element from each list and returns an int. If it evaluates to a non-zero value iteration is stopped and that value is returned.

list1 : 'T list

The first input list.

list2 : 'T list

The second input list.

Returns: int

Returns the first non-zero result from the comparison function. If the first list has a larger element, the return value is always positive. If the second list has a larger element, the return value is always negative. When the elements are equal in the two lists, 1 is returned if the first list is longer, 0 is returned if they are equal in length, and -1 is returned when the second list is longer.

List.concat lists

Full Usage: List.concat lists

Parameters:
    lists : seq<'T list> - The input sequence of lists.

Returns: 'T list The resulting concatenated list.

Returns a new list that contains the elements of each the lists in order.

lists : seq<'T list>

The input sequence of lists.

Returns: 'T list

The resulting concatenated list.

List.contains value source

Full Usage: List.contains value source

Parameters:
    value : 'T - The value to locate in the input list.
    source : 'T list - The input list.

Returns: bool True if the input list contains the specified element; false otherwise.

Tests if the list contains the specified element.

value : 'T

The value to locate in the input list.

source : 'T list

The input list.

Returns: bool

True if the input list contains the specified element; false otherwise.

List.countBy projection list

Full Usage: List.countBy projection list

Parameters:
    projection : 'T -> 'Key - A function transforming each item of the input list into a key to be compared against the others.
    list : 'T list - The input list.

Returns: ('Key * int) list The result list.

Applies a key-generating function to each element of a list and returns a list yielding unique keys and their number of occurrences in the original list.

projection : 'T -> 'Key

A function transforming each item of the input list into a key to be compared against the others.

list : 'T list

The input list.

Returns: ('Key * int) list

The result list.

List.distinct list

Full Usage: List.distinct list

Parameters:
    list : 'T list - The input list.

Returns: 'T list The result list.

Returns a list that contains no duplicate entries according to generic hash and equality comparisons on the entries. If an element occurs multiple times in the list then the later occurrences are discarded.

list : 'T list

The input list.

Returns: 'T list

The result list.

List.distinctBy projection list

Full Usage: List.distinctBy projection list

Parameters:
    projection : 'T -> 'Key - A function transforming the list items into comparable keys.
    list : 'T list - The input list.

Returns: 'T list The result list.

Returns a list that contains no duplicate entries according to the generic hash and equality comparisons on the keys returned by the given key-generating function. If an element occurs multiple times in the list then the later occurrences are discarded.

projection : 'T -> 'Key

A function transforming the list items into comparable keys.

list : 'T list

The input list.

Returns: 'T list

The result list.

List.empty

Full Usage: List.empty

Returns: 'T list

Returns an empty list of the given type.

Returns: 'T list

List.exactlyOne list

Full Usage: List.exactlyOne list

Parameters:
    list : 'T list - The input list.

Returns: 'T The only element of the list.

Returns the only element of the list.

list : 'T list

The input list.

Returns: 'T

The only element of the list.

ArgumentException Thrown when the input does not have precisely one element.

List.except itemsToExclude list

Full Usage: List.except itemsToExclude list

Parameters:
    itemsToExclude : seq<'T> - A sequence whose elements that also occur in the input list will cause those elements to be removed from the result.
    list : 'T list - A list whose elements that are not also in itemsToExclude will be returned.

Returns: 'T list A list that contains the distinct elements of list that do not appear in itemsToExclude.

Returns a new list with the distinct elements of the input list which do not appear in the itemsToExclude sequence, using generic hash and equality comparisons to compare values.

itemsToExclude : seq<'T>

A sequence whose elements that also occur in the input list will cause those elements to be removed from the result.

list : 'T list

A list whose elements that are not also in itemsToExclude will be returned.

Returns: 'T list

A list that contains the distinct elements of list that do not appear in itemsToExclude.

ArgumentNullException Thrown when itemsToExclude is null.

List.exists predicate list

Full Usage: List.exists predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: bool True if any element satisfies the predicate.

Tests 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.

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: bool

True if any element satisfies the predicate.

List.exists2 predicate list1 list2

Full Usage: List.exists2 predicate list1 list2

Parameters:
    predicate : 'T1 -> 'T2 -> bool - The function to test the input elements.
    list1 : 'T1 list - The first input list.
    list2 : 'T2 list - The second input list.

Returns: bool True if any pair of elements satisfy the predicate.

Tests 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.

predicate : 'T1 -> 'T2 -> bool

The function to test the input elements.

list1 : 'T1 list

The first input list.

list2 : 'T2 list

The second input list.

Returns: bool

True if any pair of elements satisfy the predicate.

ArgumentException Thrown when the input lists differ in length.

List.filter predicate list

Full Usage: List.filter predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: 'T list A list containing only the elements that satisfy the predicate.

Returns a new collection containing only the elements of the collection for which the given predicate returns "true"

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: 'T list

A list containing only the elements that satisfy the predicate.

List.find predicate list

Full Usage: List.find predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: 'T The first element that satisfies the predicate.

Returns the first element for which the given function returns True. Raises KeyNotFoundException if no such element exists.

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: 'T

The first element that satisfies the predicate.

KeyNotFoundException Thrown if the predicate evaluates to false for all the elements of the list.

List.findBack predicate list

Full Usage: List.findBack predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: 'T The last element that satisfies the predicate.

Returns the last element for which the given function returns True. Raises KeyNotFoundException if no such element exists.

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: 'T

The last element that satisfies the predicate.

KeyNotFoundException Thrown if the predicate evaluates to false for all the elements of the list.

List.findIndex predicate list

Full Usage: List.findIndex predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: int The index of the first element that satisfies the predicate.

Returns the index of the first element in the list that satisfies the given predicate. Raises KeyNotFoundException if no such element exists.

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: int

The index of the first element that satisfies the predicate.

ArgumentException Thrown if the predicate evaluates to false for all the elements of the list.

List.findIndexBack predicate list

Full Usage: List.findIndexBack predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: int The index of the last element that satisfies the predicate.

Returns the index of the last element in the list that satisfies the given predicate. Raises KeyNotFoundException if no such element exists.

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: int

The index of the last element that satisfies the predicate.

ArgumentException Thrown if the predicate evaluates to false for all the elements of the list.

List.fold folder state list

Full Usage: List.fold folder state list

Parameters:
    folder : 'State -> 'T -> 'State - The function to update the state given the input elements.
    state : 'State - The initial state.
    list : 'T list - The input list.

Returns: 'State The final state value.

Applies 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.

folder : 'State -> 'T -> 'State

The function to update the state given the input elements.

state : 'State

The initial state.

list : 'T list

The input list.

Returns: 'State

The final state value.

List.fold2 folder state list1 list2

Full Usage: List.fold2 folder state list1 list2

Parameters:
    folder : 'State -> 'T1 -> 'T2 -> 'State - The function to update the state given the input elements.
    state : 'State - The initial state.
    list1 : 'T1 list - The first input list.
    list2 : 'T2 list - The second input list.

Returns: 'State The final state value.

Applies 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.

folder : 'State -> 'T1 -> 'T2 -> 'State

The function to update the state given the input elements.

state : 'State

The initial state.

list1 : 'T1 list

The first input list.

list2 : 'T2 list

The second input list.

Returns: 'State

The final state value.

List.foldBack folder list state

Full Usage: List.foldBack folder list state

Parameters:
    folder : 'T -> 'State -> 'State - The function to update the state given the input elements.
    list : 'T list - The input list.
    state : 'State - The initial state.

Returns: 'State The state object after the folding function is applied to each element of the list.

Applies a function to each element of the collection, starting from the end, 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)).

folder : 'T -> 'State -> 'State

The function to update the state given the input elements.

list : 'T list

The input list.

state : 'State

The initial state.

Returns: 'State

The state object after the folding function is applied to each element of the list.

List.foldBack2 folder list1 list2 state

Full Usage: List.foldBack2 folder list1 list2 state

Parameters:
    folder : 'T1 -> 'T2 -> 'State -> 'State - The function to update the state given the input elements.
    list1 : 'T1 list - The first input list.
    list2 : 'T2 list - The second input list.
    state : 'State - The initial state.

Returns: 'State The final state value.

Applies 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)).

folder : 'T1 -> 'T2 -> 'State -> 'State

The function to update the state given the input elements.

list1 : 'T1 list

The first input list.

list2 : 'T2 list

The second input list.

state : 'State

The initial state.

Returns: 'State

The final state value.

List.forall predicate list

Full Usage: List.forall predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: bool True if all of the elements satisfy the predicate.

Tests 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.

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: bool

True if all of the elements satisfy the predicate.

List.forall2 predicate list1 list2

Full Usage: List.forall2 predicate list1 list2

Parameters:
    predicate : 'T1 -> 'T2 -> bool - The function to test the input elements.
    list1 : 'T1 list - The first input list.
    list2 : 'T2 list - The second input list.

Returns: bool True if all of the pairs of elements satisfy the predicate.

Tests 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.

predicate : 'T1 -> 'T2 -> bool

The function to test the input elements.

list1 : 'T1 list

The first input list.

list2 : 'T2 list

The second input list.

Returns: bool

True if all of the pairs of elements satisfy the predicate.

ArgumentException Thrown when the input lists differ in length.

List.groupBy projection list

Full Usage: List.groupBy projection list

Parameters:
    projection : 'T -> 'Key - A function that transforms an element of the list into a comparable key.
    list : 'T list - The input list.

Returns: ('Key * 'T list) list The result list.

Applies a key-generating function to each element of a list and yields a list of unique keys. Each unique key contains a list of all elements that match to this key.

projection : 'T -> 'Key

A function that transforms an element of the list into a comparable key.

list : 'T list

The input list.

Returns: ('Key * 'T list) list

The result list.

List.head list

Full Usage: List.head list

Parameters:
    list : 'T list - The input list.

Returns: 'T The first element of the list.

Returns the first element of the list.

list : 'T list

The input list.

Returns: 'T

The first element of the list.

ArgumentException Thrown when the list is empty.

List.indexed list

Full Usage: List.indexed list

Parameters:
    list : 'T list - The input list.

Returns: (int * 'T) list The list of indexed elements.

Returns a new list whose elements are the corresponding elements of the input list paired with the index (from 0) of each element.

list : 'T list

The input list.

Returns: (int * 'T) list

The list of indexed elements.

List.init length initializer

Full Usage: List.init length initializer

Parameters:
    length : int - The length of the list to generate.
    initializer : int -> 'T - The function to generate an element from an index.

Returns: 'T list The list of generated elements.

Creates a list by calling the given generator on each index.

length : int

The length of the list to generate.

initializer : int -> 'T

The function to generate an element from an index.

Returns: 'T list

The list of generated elements.

List.isEmpty list

Full Usage: List.isEmpty list

Parameters:
    list : 'T list - The input list.

Returns: bool True if the list is empty.

Returns true if the list contains no elements, false otherwise.

list : 'T list

The input list.

Returns: bool

True if the list is empty.

List.item index list

Full Usage: List.item index list

Parameters:
    index : int - The index to retrieve.
    list : 'T list - The input list.

Returns: 'T The value at the given index.

Indexes into the list. The first element has index 0.

index : int

The index to retrieve.

list : 'T list

The input list.

Returns: 'T

The value at the given index.

ArgumentException Thrown when the index is negative or the input list does not contain enough elements.

List.iter action list

Full Usage: List.iter action list

Parameters:
    action : 'T -> unit - The function to apply to elements from the input list.
    list : 'T list - The input list.

Applies the given function to each element of the collection.

action : 'T -> unit

The function to apply to elements from the input list.

list : 'T list

The input list.

List.iter2 action list1 list2

Full Usage: List.iter2 action list1 list2

Parameters:
    action : 'T1 -> 'T2 -> unit - The function to apply to pairs of elements from the input lists.
    list1 : 'T1 list - The first input list.
    list2 : 'T2 list - The second input list.

Applies the given function to two collections simultaneously. The collections must have identical size.

action : 'T1 -> 'T2 -> unit

The function to apply to pairs of elements from the input lists.

list1 : 'T1 list

The first input list.

list2 : 'T2 list

The second input list.

List.iteri action list

Full Usage: List.iteri action list

Parameters:
    action : int -> 'T -> unit - The function to apply to the elements of the list along with their index.
    list : 'T list - The input list.

Applies the given function to each element of the collection. The integer passed to the function indicates the index of element.

action : int -> 'T -> unit

The function to apply to the elements of the list along with their index.

list : 'T list

The input list.

List.iteri2 action list1 list2

Full Usage: List.iteri2 action list1 list2

Parameters:
    action : int -> 'T1 -> 'T2 -> unit - The function to apply to a pair of elements from the input lists along with their index.
    list1 : 'T1 list - The first input list.
    list2 : 'T2 list - The second input list.

Applies the given function to two collections simultaneously. The collections must have identical size. The integer passed to the function indicates the index of element.

action : int -> 'T1 -> 'T2 -> unit

The function to apply to a pair of elements from the input lists along with their index.

list1 : 'T1 list

The first input list.

list2 : 'T2 list

The second input list.

List.last list

Full Usage: List.last list

Parameters:
    list : 'T list - The input list.

Returns: 'T The last element of the list.

Returns the last element of the list.

list : 'T list

The input list.

Returns: 'T

The last element of the list.

ArgumentException Thrown when the input does not have any elements.

List.length list

Full Usage: List.length list

Parameters:
    list : 'T list - The input list.

Returns: int The length of the list.

Returns the length of the list.

list : 'T list

The input list.

Returns: int

The length of the list.

List.map mapping list

Full Usage: List.map mapping list

Parameters:
    mapping : 'T -> 'U - The function to transform elements from the input list.
    list : 'T list - The input list.

Returns: 'U list The list of transformed elements.

Builds a new collection whose elements are the results of applying the given function to each of the elements of the collection.

mapping : 'T -> 'U

The function to transform elements from the input list.

list : 'T list

The input list.

Returns: 'U list

The list of transformed elements.

List.map2 mapping list1 list2

Full Usage: List.map2 mapping list1 list2

Parameters:
    mapping : 'T1 -> 'T2 -> 'U - The function to transform pairs of elements from the input lists.
    list1 : 'T1 list - The first input list.
    list2 : 'T2 list - The second input list.

Returns: 'U list The list of transformed elements.

Builds a new collection whose elements are the results of applying the given function to the corresponding elements of the two collections pairwise.

mapping : 'T1 -> 'T2 -> 'U

The function to transform pairs of elements from the input lists.

list1 : 'T1 list

The first input list.

list2 : 'T2 list

The second input list.

Returns: 'U list

The list of transformed elements.

List.map3 mapping list1 list2 list3

Full Usage: List.map3 mapping list1 list2 list3

Parameters:
    mapping : 'T1 -> 'T2 -> 'T3 -> 'U - The function to transform triples of elements from the input lists.
    list1 : 'T1 list - The first input list.
    list2 : 'T2 list - The second input list.
    list3 : 'T3 list - The third input list.

Returns: 'U list The list of transformed elements.

Builds a new collection whose elements are the results of applying the given function to the corresponding elements of the three collections simultaneously.

mapping : 'T1 -> 'T2 -> 'T3 -> 'U

The function to transform triples of elements from the input lists.

list1 : 'T1 list

The first input list.

list2 : 'T2 list

The second input list.

list3 : 'T3 list

The third input list.

Returns: 'U list

The list of transformed elements.

List.mapFold mapping state list

Full Usage: List.mapFold mapping state list

Parameters:
    mapping : 'State -> 'T -> 'Result * 'State - The function to transform elements from the input list and accumulate the final value.
    state : 'State - The initial state.
    list : 'T list - The input list.

Returns: 'Result list * 'State The list of transformed elements, and the final accumulated value.

Combines map and fold. Builds a new list whose elements are the results of applying the given function to each of the elements of the input list. The function is also used to accumulate a final value.

mapping : 'State -> 'T -> 'Result * 'State

The function to transform elements from the input list and accumulate the final value.

state : 'State

The initial state.

list : 'T list

The input list.

Returns: 'Result list * 'State

The list of transformed elements, and the final accumulated value.

List.mapFoldBack mapping list state

Full Usage: List.mapFoldBack mapping list state

Parameters:
    mapping : 'T -> 'State -> 'Result * 'State - The function to transform elements from the input list and accumulate the final value.
    list : 'T list - The input list.
    state : 'State - The initial state.

Returns: 'Result list * 'State The list of transformed elements, and the final accumulated value.

Combines map and foldBack. Builds a new list whose elements are the results of applying the given function to each of the elements of the input list. The function is also used to accumulate a final value.

mapping : 'T -> 'State -> 'Result * 'State

The function to transform elements from the input list and accumulate the final value.

list : 'T list

The input list.

state : 'State

The initial state.

Returns: 'Result list * 'State

The list of transformed elements, and the final accumulated value.

List.mapi mapping list

Full Usage: List.mapi mapping list

Parameters:
    mapping : int -> 'T -> 'U - The function to transform elements and their indices.
    list : 'T list - The input list.

Returns: 'U list The list of transformed elements.

Builds 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.

mapping : int -> 'T -> 'U

The function to transform elements and their indices.

list : 'T list

The input list.

Returns: 'U list

The list of transformed elements.

List.mapi2 mapping list1 list2

Full Usage: List.mapi2 mapping list1 list2

Parameters:
    mapping : int -> 'T1 -> 'T2 -> 'U - The function to transform pairs of elements from the two lists and their index.
    list1 : 'T1 list - The first input list.
    list2 : 'T2 list - The second input list.

Returns: 'U list The list of transformed elements.

Like mapi, but mapping corresponding elements from two lists of equal length.

mapping : int -> 'T1 -> 'T2 -> 'U

The function to transform pairs of elements from the two lists and their index.

list1 : 'T1 list

The first input list.

list2 : 'T2 list

The second input list.

Returns: 'U list

The list of transformed elements.

List.max list

Full Usage: List.max list

Parameters:
    list : 'T list - The input list.

Returns: 'T The maximum element.

Return the greatest of all elements of the list, compared via Operators.max.

Raises ArgumentException if list is empty

list : 'T list

The input list.

Returns: 'T

The maximum element.

ArgumentException Thrown when the list is empty.

List.maxBy projection list

Full Usage: List.maxBy projection list

Parameters:
    projection : 'T -> 'U - The function to transform the list elements into the type to be compared.
    list : 'T list - The input list.

Returns: 'T The maximum element.

Returns the greatest of all elements of the list, compared via Operators.max on the function result.

Raises ArgumentException if list is empty.

projection : 'T -> 'U

The function to transform the list elements into the type to be compared.

list : 'T list

The input list.

Returns: 'T

The maximum element.

ArgumentException Thrown when the list is empty.

List.min list

Full Usage: List.min list

Parameters:
    list : 'T list - The input list.

Returns: 'T The minimum value.

Returns the lowest of all elements of the list, compared via Operators.min.

Raises ArgumentException if list is empty

list : 'T list

The input list.

Returns: 'T

The minimum value.

ArgumentException Thrown when the list is empty.

List.minBy projection list

Full Usage: List.minBy projection list

Parameters:
    projection : 'T -> 'U - The function to transform list elements into the type to be compared.
    list : 'T list - The input list.

Returns: 'T The minimum value.

Returns the lowest of all elements of the list, compared via Operators.min on the function result

Raises ArgumentException if list is empty.

projection : 'T -> 'U

The function to transform list elements into the type to be compared.

list : 'T list

The input list.

Returns: 'T

The minimum value.

ArgumentException Thrown when the list is empty.

List.ofArray array

Full Usage: List.ofArray array

Parameters:
    array : 'T[] - The input array.

Returns: 'T list The list of elements from the array.

Builds a list from the given array.

array : 'T[]

The input array.

Returns: 'T list

The list of elements from the array.

List.ofSeq source

Full Usage: List.ofSeq source

Parameters:
    source : seq<'T> - The input sequence.

Returns: 'T list The list of elements from the sequence.

Builds a new list from the given enumerable object.

source : seq<'T>

The input sequence.

Returns: 'T list

The list of elements from the sequence.

List.pairwise list

Full Usage: List.pairwise list

Parameters:
    list : 'T list - The input list.

Returns: ('T * 'T) list The result list.

Returns a list of each element in the input list and its predecessor, with the exception of the first element which is only returned as the predecessor of the second element.

list : 'T list

The input list.

Returns: ('T * 'T) list

The result list.

List.partition predicate list

Full Usage: List.partition predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: 'T list * 'T list A list containing the elements for which the predicate evaluated to false and a list containing the elements for which the predicate evaluated to true.

Splits the collection into two collections, containing the elements for which the given predicate returns True and False respectively. Element order is preserved in both of the created lists.

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: 'T list * 'T list

A list containing the elements for which the predicate evaluated to false and a list containing the elements for which the predicate evaluated to true.

List.permute indexMap list

Full Usage: List.permute indexMap list

Parameters:
    indexMap : int -> int - The function to map input indices to output indices.
    list : 'T list - The input list.

Returns: 'T list The permuted list.

Returns a list with all elements permuted according to the specified permutation.

indexMap : int -> int

The function to map input indices to output indices.

list : 'T list

The input list.

Returns: 'T list

The permuted list.

ArgumentException Thrown when indexMap does not produce a valid permutation.

List.pick chooser list

Full Usage: List.pick chooser list

Parameters:
    chooser : 'T -> 'U option - The function to generate options from the elements.
    list : 'T list - The input list.

Returns: 'U The first resulting value.

Applies 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 KeyNotFoundException

chooser : 'T -> 'U option

The function to generate options from the elements.

list : 'T list

The input list.

Returns: 'U

The first resulting value.

KeyNotFoundException Thrown when the list is empty.

List.reduce reduction list

Full Usage: List.reduce reduction list

Parameters:
    reduction : 'T -> 'T -> 'T - The function to reduce two list elements to a single element.
    list : 'T list - The input list.

Returns: 'T The final reduced value.

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 list is empty

reduction : 'T -> 'T -> 'T

The function to reduce two list elements to a single element.

list : 'T list

The input list.

Returns: 'T

The final reduced value.

ArgumentException Thrown when the list is empty.

List.reduceBack reduction list

Full Usage: List.reduceBack reduction list

Parameters:
    reduction : 'T -> 'T -> 'T - A function that takes in the next-to-last element of the list and the current accumulated result to produce the next accumulated result.
    list : 'T list - The input list.

Returns: 'T The final result of the reductions.

Applies a function to each element of the collection, starting from the end, 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)).

reduction : 'T -> 'T -> 'T

A function that takes in the next-to-last element of the list and the current accumulated result to produce the next accumulated result.

list : 'T list

The input list.

Returns: 'T

The final result of the reductions.

ArgumentException Thrown when the list is empty.

List.replicate count initial

Full Usage: List.replicate count initial

Parameters:
    count : int - The number of elements to replicate.
    initial : 'T - The value to replicate

Returns: 'T list The generated list.

Creates a list by replicating the given initial value.

count : int

The number of elements to replicate.

initial : 'T

The value to replicate

Returns: 'T list

The generated list.

List.rev list

Full Usage: List.rev list

Parameters:
    list : 'T list - The input list.

Returns: 'T list The reversed list.

Returns a new list with the elements in reverse order.

list : 'T list

The input list.

Returns: 'T list

The reversed list.

List.scan folder state list

Full Usage: List.scan folder state list

Parameters:
    folder : 'State -> 'T -> 'State - The function to update the state given the input elements.
    state : 'State - The initial state.
    list : 'T list - The input list.

Returns: 'State list The list of states.

Applies 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. Returns the list of intermediate results and the final result.

folder : 'State -> 'T -> 'State

The function to update the state given the input elements.

state : 'State

The initial state.

list : 'T list

The input list.

Returns: 'State list

The list of states.

List.scanBack folder list state

Full Usage: List.scanBack folder list state

Parameters:
    folder : 'T -> 'State -> 'State - The function to update the state given the input elements.
    list : 'T list - The input list.
    state : 'State - The initial state.

Returns: 'State list The list of states.

Like foldBack, but returns both the intermediary and final results

folder : 'T -> 'State -> 'State

The function to update the state given the input elements.

list : 'T list

The input list.

state : 'State

The initial state.

Returns: 'State list

The list of states.

List.singleton value

Full Usage: List.singleton value

Parameters:
    value : 'T - The input item.

Returns: 'T list The result list of one item.

Returns a list that contains one item only.

value : 'T

The input item.

Returns: 'T list

The result list of one item.

List.skip count list

Full Usage: List.skip count list

Parameters:
    count : int - The number of elements to skip.
    list : 'T list - The input list.

Returns: 'T list The list after removing the first N elements.

Returns the list after removing the first N elements.

count : int

The number of elements to skip.

list : 'T list

The input list.

Returns: 'T list

The list after removing the first N elements.

ArgumentException Thrown when count is negative or exceeds the number of elements in the list.

List.skipWhile predicate list

Full Usage: List.skipWhile predicate list

Parameters:
    predicate : 'T -> bool - A function that evaluates an element of the list to a boolean value.
    list : 'T list - The input list.

Returns: 'T list The result list.

Bypasses elements in a list while the given predicate returns True, and then returns the remaining elements of the list.

predicate : 'T -> bool

A function that evaluates an element of the list to a boolean value.

list : 'T list

The input list.

Returns: 'T list

The result list.

List.sort list

Full Usage: List.sort list

Parameters:
    list : 'T list - The input list.

Returns: 'T list The sorted list.

Sorts the given list using Operators.compare.

This is a stable sort, i.e. the original order of equal elements is preserved.

list : 'T list

The input list.

Returns: 'T list

The sorted list.

List.sortBy projection list

Full Usage: List.sortBy projection list

Parameters:
    projection : 'T -> 'Key - The function to transform the list elements into the type to be compared.
    list : 'T list - The input list.

Returns: 'T list The sorted list.

Sorts the given list using keys given by the given projection. Keys are compared using Operators.compare.

This is a stable sort, i.e. the original order of equal elements is preserved.

projection : 'T -> 'Key

The function to transform the list elements into the type to be compared.

list : 'T list

The input list.

Returns: 'T list

The sorted list.

List.sortByDescending projection list

Full Usage: List.sortByDescending projection list

Parameters:
    projection : 'T -> 'Key - The function to transform the list elements into the type to be compared.
    list : 'T list - The input list.

Returns: 'T list The sorted list.

Sorts the given list in descending order using keys given by the given projection. Keys are compared using Operators.compare.

This is a stable sort, i.e. the original order of equal elements is preserved.

projection : 'T -> 'Key

The function to transform the list elements into the type to be compared.

list : 'T list

The input list.

Returns: 'T list

The sorted list.

List.sortDescending list

Full Usage: List.sortDescending list

Parameters:
    list : 'T list - The input list.

Returns: 'T list The sorted list.

Sorts the given list in descending order using Operators.compare.

This is a stable sort, i.e. the original order of equal elements is preserved.

list : 'T list

The input list.

Returns: 'T list

The sorted list.

List.sortWith comparer list

Full Usage: List.sortWith comparer list

Parameters:
    comparer : 'T -> 'T -> int - The function to compare the list elements.
    list : 'T list - The input list.

Returns: 'T list The sorted list.

Sorts the given list using the given comparison function.

This is a stable sort, i.e. the original order of equal elements is preserved.

comparer : 'T -> 'T -> int

The function to compare the list elements.

list : 'T list

The input list.

Returns: 'T list

The sorted list.

List.splitAt index list

Full Usage: List.splitAt index list

Parameters:
    index : int - The index at which the list is split.
    list : 'T list - The input list.

Returns: 'T list * 'T list The two split lists.

Splits a list into two lists, at the given index.

index : int

The index at which the list is split.

list : 'T list

The input list.

Returns: 'T list * 'T list

The two split lists.

InvalidOperationException Thrown when split index exceeds the number of elements in the list.

List.splitInto count list

Full Usage: List.splitInto count list

Parameters:
    count : int - The maximum number of chunks.
    list : 'T list - The input list.

Returns: 'T list list The list split into chunks.

Splits the input list into at most count chunks.

count : int

The maximum number of chunks.

list : 'T list

The input list.

Returns: 'T list list

The list split into chunks.

ArgumentException Thrown when count is not positive.

List.sum list

Full Usage: List.sum list

Parameters:
    list : ^T list - The input list.

Returns: ^T The resulting sum.

Returns the sum of the elements in the list.

list : ^T list

The input list.

Returns: ^T

The resulting sum.

List.sumBy projection list

Full Usage: List.sumBy projection list

Parameters:
    projection : 'T -> ^U - The function to transform the list elements into the type to be summed.
    list : 'T list - The input list.

Returns: ^U The resulting sum.

Returns the sum of the results generated by applying the function to each element of the list.

projection : 'T -> ^U

The function to transform the list elements into the type to be summed.

list : 'T list

The input list.

Returns: ^U

The resulting sum.

List.tail list

Full Usage: List.tail list

Parameters:
    list : 'T list - The input list.

Returns: 'T list The list after removing the first element.

Returns the list after removing the first element.

list : 'T list

The input list.

Returns: 'T list

The list after removing the first element.

ArgumentException Thrown when the list is empty.

List.take count list

Full Usage: List.take count list

Parameters:
    count : int - The number of items to take.
    list : 'T list - The input list.

Returns: 'T list The result list.

Returns the first N elements of the list.

Throws InvalidOperationException if the count exceeds the number of elements in the list. List.truncate returns as many items as the list contains instead of throwing an exception.

count : int

The number of items to take.

list : 'T list

The input list.

Returns: 'T list

The result list.

ArgumentException Thrown when the input list is empty.
InvalidOperationException Thrown when count exceeds the number of elements in the list.

List.takeWhile predicate list

Full Usage: List.takeWhile predicate list

Parameters:
    predicate : 'T -> bool - A function that evaluates to false when no more items should be returned.
    list : 'T list - The input list.

Returns: 'T list The result list.

Returns a list that contains all elements of the original list while the given predicate returns True, and then returns no further elements.

predicate : 'T -> bool

A function that evaluates to false when no more items should be returned.

list : 'T list

The input list.

Returns: 'T list

The result list.

List.toArray list

Full Usage: List.toArray list

Parameters:
    list : 'T list - The input list.

Returns: 'T[] The array containing the elements of the list.

Builds an array from the given list.

list : 'T list

The input list.

Returns: 'T[]

The array containing the elements of the list.

List.toSeq list

Full Usage: List.toSeq list

Parameters:
    list : 'T list - The input list.

Returns: seq<'T> The sequence of elements in the list.

Views the given list as a sequence.

list : 'T list

The input list.

Returns: seq<'T>

The sequence of elements in the list.

List.transpose lists

Full Usage: List.transpose lists

Parameters:
    lists : seq<'T list> - The input sequence of list.

Returns: 'T list list The transposed list.

Returns the transpose of the given sequence of lists.

lists : seq<'T list>

The input sequence of list.

Returns: 'T list list

The transposed list.

ArgumentNullException Thrown when the input sequence is null.
ArgumentException Thrown when the input lists differ in length.

List.truncate count list

Full Usage: List.truncate count list

Parameters:
    count : int - The maximum number of items to return.
    list : 'T list

Returns: 'T list The result list.

Returns at most N elements in a new list.

count : int

The maximum number of items to return.

list : 'T list
Returns: 'T list

The result list.

List.tryExactlyOne list

Full Usage: List.tryExactlyOne list

Parameters:
    list : 'T list - The input list.

Returns: 'T option The only element of the list or None.

Returns the only element of the list or None if it is empty or contains more than one element.

list : 'T list

The input list.

Returns: 'T option

The only element of the list or None.

List.tryFind predicate list

Full Usage: List.tryFind predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: 'T option The first element for which the predicate returns true, or None if every element evaluates to false.

Returns the first element for which the given function returns True. Return None if no such element exists.

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: 'T option

The first element for which the predicate returns true, or None if every element evaluates to false.

List.tryFindBack predicate list

Full Usage: List.tryFindBack predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: 'T option The last element for which the predicate returns true, or None if every element evaluates to false.

Returns the last element for which the given function returns True. Return None if no such element exists.

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: 'T option

The last element for which the predicate returns true, or None if every element evaluates to false.

List.tryFindIndex predicate list

Full Usage: List.tryFindIndex predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: int option The index of the first element for which the predicate returns true, or None if every element evaluates to false.

Returns the index of the first element in the list that satisfies the given predicate. Return None if no such element exists.

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: int option

The index of the first element for which the predicate returns true, or None if every element evaluates to false.

List.tryFindIndexBack predicate list

Full Usage: List.tryFindIndexBack predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: int option The index of the last element for which the predicate returns true, or None if every element evaluates to false.

Returns the index of the last element in the list that satisfies the given predicate. Return None if no such element exists.

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: int option

The index of the last element for which the predicate returns true, or None if every element evaluates to false.

List.tryHead list

Full Usage: List.tryHead list

Parameters:
    list : 'T list - The input list.

Returns: 'T option The first element of the list or None.

Returns the first element of the list, or None if the list is empty.

list : 'T list

The input list.

Returns: 'T option

The first element of the list or None.

List.tryItem index list

Full Usage: List.tryItem index list

Parameters:
    index : int - The index to retrieve.
    list : 'T list - The input list.

Returns: 'T option The value at the given index or None.

Tries to find the nth element in the list. Returns None if index is negative or the list does not contain enough elements.

index : int

The index to retrieve.

list : 'T list

The input list.

Returns: 'T option

The value at the given index or None.

List.tryLast list

Full Usage: List.tryLast list

Parameters:
    list : 'T list - The input list.

Returns: 'T option The last element of the list or None.

Returns the last element of the list. Return None if no such element exists.

list : 'T list

The input list.

Returns: 'T option

The last element of the list or None.

List.tryPick chooser list

Full Usage: List.tryPick chooser list

Parameters:
    chooser : 'T -> 'U option - The function to generate options from the elements.
    list : 'T list - The input list.

Returns: 'U option The first resulting value or None.

Applies 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.

chooser : 'T -> 'U option

The function to generate options from the elements.

list : 'T list

The input list.

Returns: 'U option

The first resulting value or None.

List.unfold generator state

Full Usage: List.unfold generator state

Parameters:
    generator : 'State -> ('T * 'State) option - A function that takes in the current state and returns an option tuple of the next element of the list and the next state value.
    state : 'State - The initial state value.

Returns: 'T list The result list.

Returns a list that contains the elements generated by the given computation. The given initial state argument is passed to the element generator.

generator : 'State -> ('T * 'State) option

A function that takes in the current state and returns an option tuple of the next element of the list and the next state value.

state : 'State

The initial state value.

Returns: 'T list

The result list.

List.unzip list

Full Usage: List.unzip list

Parameters:
    list : ('T1 * 'T2) list - The input list.

Returns: 'T1 list * 'T2 list Two lists of split elements.

Splits a list of pairs into two lists.

list : ('T1 * 'T2) list

The input list.

Returns: 'T1 list * 'T2 list

Two lists of split elements.

List.unzip3 list

Full Usage: List.unzip3 list

Parameters:
    list : ('T1 * 'T2 * 'T3) list - The input list.

Returns: 'T1 list * 'T2 list * 'T3 list Three lists of split elements.

Splits a list of triples into three lists.

list : ('T1 * 'T2 * 'T3) list

The input list.

Returns: 'T1 list * 'T2 list * 'T3 list

Three lists of split elements.

List.where predicate list

Full Usage: List.where predicate list

Parameters:
    predicate : 'T -> bool - The function to test the input elements.
    list : 'T list - The input list.

Returns: 'T list A list containing only the elements that satisfy the predicate.

Returns a new list containing only the elements of the list for which the given predicate returns "true"

predicate : 'T -> bool

The function to test the input elements.

list : 'T list

The input list.

Returns: 'T list

A list containing only the elements that satisfy the predicate.

List.windowed windowSize list

Full Usage: List.windowed windowSize list

Parameters:
    windowSize : int - The number of elements in each window.
    list : 'T list - The input list.

Returns: 'T list list The result list.

Returns a list of sliding windows containing elements drawn from the input list. Each window is returned as a fresh list.

windowSize : int

The number of elements in each window.

list : 'T list

The input list.

Returns: 'T list list

The result list.

ArgumentException Thrown when windowSize is not positive.

List.zip list1 list2

Full Usage: List.zip list1 list2

Parameters:
    list1 : 'T1 list - The first input list.
    list2 : 'T2 list - The second input list.

Returns: ('T1 * 'T2) list A single list containing pairs of matching elements from the input lists.

Combines the two lists into a list of pairs. The two lists must have equal lengths.

list1 : 'T1 list

The first input list.

list2 : 'T2 list

The second input list.

Returns: ('T1 * 'T2) list

A single list containing pairs of matching elements from the input lists.

List.zip3 list1 list2 list3

Full Usage: List.zip3 list1 list2 list3

Parameters:
    list1 : 'T1 list - The first input list.
    list2 : 'T2 list - The second input list.
    list3 : 'T3 list - The third input list.

Returns: ('T1 * 'T2 * 'T3) list A single list containing triples of matching elements from the input lists.

Combines the three lists into a list of triples. The lists must have equal lengths.

list1 : 'T1 list

The first input list.

list2 : 'T2 list

The second input list.

list3 : 'T3 list

The third input list.

Returns: ('T1 * 'T2 * 'T3) list

A single list containing triples of matching elements from the input lists.