FSharpPlus


List Module

Additional operations on List

Functions and values

Function or value Description

List.apply f x

Full Usage: List.apply f x

Parameters:
    f : ('a -> 'b) list - The list of functions.
    x : 'a list - The list of values.

Returns: 'b list A concatenated list of the result lists of applying each function to each value

Applies a list of functions to a list of values and concatenates them

f : ('a -> 'b) list

The list of functions.

x : 'a list

The list of values.

Returns: 'b list

A concatenated list of the result lists of applying each function to each value

Example


 > List.apply [double; triple] [1; 2; 3];;  
 val it : int list = [2; 4; 6; 3; 6; 9]

List.choosei mapping source

Full Usage: List.choosei mapping source

Parameters:
    mapping : int -> 'b -> 'c option - The mapping function, taking index and element as parameters.
    source : 'b list - The input list.

Returns: 'c list List with values x for each List value where the function returns Some(x).

Same as choose but with access to the index.

mapping : int -> 'b -> 'c option

The mapping function, taking index and element as parameters.

source : 'b list

The input list.

Returns: 'c list

List with values x for each List value where the function returns Some(x).

List.cons x list

Full Usage: List.cons x list

Parameters:
    x : 'f - The element to add
    list : 'f list - The list to add to

Returns: 'f list A concatenated list of the result lists of applying each function to each value

Adds an element to the beginning of the given list

x : 'f

The element to add

list : 'f list

The list to add to

Returns: 'f list

A concatenated list of the result lists of applying each function to each value

List.drop count source

Full Usage: List.drop count source

Parameters:
    count : int - The number of items to drop.
    source : 'b list - The input list.

Returns: 'b list The result list.

Returns a list that drops N elements of the original list and then yields the remaining elements of the list.

When count exceeds the number of elements in the list it returns an empty list instead of throwing an exception.

count : int

The number of items to drop.

source : 'b list

The input list.

Returns: 'b list

The result list.

List.findSliceIndex slice source

Full Usage: List.findSliceIndex slice source

Parameters:
    slice : 'b list
    source : 'b list

Returns: int The index of the slice.

Gets the index of the first occurrence of the specified slice in the source.

slice : 'b list
source : 'b list
Returns: int

The index of the slice.

ArgumentException Thrown when the slice was not found in the sequence.

List.intercalate separator source

Full Usage: List.intercalate separator source

Parameters:
    separator : 'a list
    source : seq<'a list>

Returns: 'a list

Concatenates all elements, using the specified separator between each element.

separator : 'a list
source : seq<'a list>
Returns: 'a list

List.intersperse element source

Full Usage: List.intersperse element source

Parameters:
    element : 'T
    source : 'T list

Returns: 'T list

Inserts a separator element between each element in the source list.

element : 'T
source : 'T list
Returns: 'T list

List.lift2 f x1 x2

Full Usage: List.lift2 f x1 x2

Parameters:
    f : 'd -> 'e -> 'f
    x1 : 'd list
    x2 : 'e list

Returns: 'f list

Combines all values from the first list with the second, using the supplied mapping function.

f : 'd -> 'e -> 'f
x1 : 'd list
x2 : 'e list
Returns: 'f list

List.lift3 f x1 x2 x3

Full Usage: List.lift3 f x1 x2 x3

Parameters:
    f : 'e -> 'f -> 'g -> 'h - Mapping function taking three element combination as input.
    x1 : 'g list - First list.
    x2 : 'e list - Second list.
    x3 : 'f list - Third list.

Returns: 'h list List with values returned from mapping function.

Combines values from three list and calls a mapping function on this combination.

f : 'e -> 'f -> 'g -> 'h

Mapping function taking three element combination as input.

x1 : 'g list

First list.

x2 : 'e list

Second list.

x3 : 'f list

Third list.

Returns: 'h list

List with values returned from mapping function.

List.map2Shortest f l1 l2

Full Usage: List.map2Shortest f l1 l2

Parameters:
    f : 'd -> 'e -> 'f
    l1 : 'd list
    l2 : 'e list

Returns: 'f list

Safely build a new list whose elements are the results of applying the given function to each of the elements of the two lists pairwise.

f : 'd -> 'e -> 'f
l1 : 'd list
l2 : 'e list
Returns: 'f list

List.partitionMap mapping source

Full Usage: List.partitionMap mapping source

Parameters:
    mapping : 'T -> Choice<'T1, 'T2>
    source : 'T list

Returns: 'T1 list * 'T2 list A tuple with both resulting lists.

Creates two lists by applying the mapping function to each element in the list and classifying the transformed values depending on whether they were wrapped with Choice1Of2 or Choice2Of2.

mapping : 'T -> Choice<'T1, 'T2>
source : 'T list
Returns: 'T1 list * 'T2 list

A tuple with both resulting lists.

List.removeAt i lst

Full Usage: List.removeAt i lst

Parameters:
    i : int - The index of the item to remove
    lst : 'd list - The input list

Returns: 'd list For invalid indexes, the input list. Otherwise, a new list with the item removed.

Attempts to remove an item from a list.

i : int

The index of the item to remove

lst : 'd list

The input list

Returns: 'd list

For invalid indexes, the input list. Otherwise, a new list with the item removed.

List.replace oldValue newValue source

Full Usage: List.replace oldValue newValue source

Parameters:
    oldValue : seq<'T>
    newValue : 'T list
    source : 'T list

Returns: 'T list

Replaces a subsequence of the source list with the given replacement list.

oldValue : seq<'T>
newValue : 'T list
source : 'T list
Returns: 'T list

List.setAt i x lst

Full Usage: List.setAt i x lst

Parameters:
    i : int - The index of the item to update
    x : 'd - The new value of the item
    lst : 'd list - The input list

Returns: 'd list A new list with the updated element

Updates the value of an item in a list

i : int

The index of the item to update

x : 'd

The new value of the item

lst : 'd list

The input list

Returns: 'd list

A new list with the updated element

List.singleton x

Full Usage: List.singleton x

Parameters:
    x : 'c

Returns: 'c list

Creates a list with a single element.

x : 'c
Returns: 'c list

List.skip i list

Full Usage: List.skip i list

Parameters:
    i : int
    list : 'a list

Returns: 'a list
i : int
list : 'a list
Returns: 'a list

List.split separators source

Full Usage: List.split separators source

Parameters:
    separators : seq<'a list>
    source : 'a list

Returns: seq<'a list>

Creates a sequence of lists by splitting the source list on any of the given separators.

separators : seq<'a list>
source : 'a list
Returns: seq<'a list>

List.tails x

Full Usage: List.tails x

Parameters:
    x : 'a list

Returns: 'a list list

Returns a list with all possible tails of the source list.

x : 'a list
Returns: 'a list list

List.take i list

Full Usage: List.take i list

Parameters:
    i : int
    list : seq<'a>

Returns: 'a list
i : int
list : seq<'a>
Returns: 'a list

List.toIReadOnlyList source

Full Usage: List.toIReadOnlyList source

Parameters:
    source : 'a list - The list source

Returns: IReadOnlyList<'a> The list converted to a System.Collections.Generic.IReadOnlyList

Converts a list to an IReadOnlyList (from System.Collections.Generic).

source : 'a list

The list source

Returns: IReadOnlyList<'a>

The list converted to a System.Collections.Generic.IReadOnlyList

List.tryFindSliceIndex slice source

Full Usage: List.tryFindSliceIndex slice source

Parameters:
    slice : 'b list
    source : 'b list

Returns: int option The index of the slice or None.

Gets the index of the first occurrence of the specified slice in the source. Returns None if not found.

slice : 'b list
source : 'b list
Returns: int option

The index of the slice or None.

List.zipShortest list1 list2

Full Usage: List.zipShortest list1 list2

Parameters:
    list1 : 'T1 list - First input list.
    list2 : 'T2 list - Second input list.

Returns: ('T1 * 'T2) list List with corresponding pairs of input lists.

Zip safely two lists. If one list is shorter, excess elements are discarded from the right end of the longer list.

list1 : 'T1 list

First input list.

list2 : 'T2 list

Second input list.

Returns: ('T1 * 'T2) list

List with corresponding pairs of input lists.