Additional operations on List
Function or value | Description | ||||
Full Usage:
List.apply f x
Parameters:
('T -> 'U) list
-
The list of functions.
x : 'T list
-
The list of values.
Returns: 'U list
A concatenated list of the result lists of applying each function to each value
|
Example
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... Multiple items
val double: value: 'T -> double (requires member op_Explicit) -------------------- type double = System.Double -------------------- type double<'Measure> = float<'Measure> Multiple items
val int: value: 'T -> int (requires member op_Explicit) -------------------- type int = int32 -------------------- type int<'Measure> = int type 'T list = List<'T>
|
||||
Full Usage:
List.choosei mapping source
Parameters:
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).
|
|||||
Full Usage:
List.chunkBy projection source
Parameters:
'T -> 'Key
-
A function that transforms an element of the list into a comparable key.
source : 'T list
-
The input list.
Returns: ('Key * 'T list) list
The resulting list of keys tupled with a list of matching values
|
Each key is tupled with an array of all adjacent elements that match to the key, therefore keys are not unique but can't be adjacent as each time the key changes a new group is yield. The ordering of the original list is respected.
|
||||
Full Usage:
List.cons value list
Parameters:
'T
-
The element to add
list : 'T list
-
The list to add to
Returns: 'T list
A concatenated list of the result lists of applying each function to each value
|
Note: this function has since been added to FSharp.Core. It will be removed in next major release of FSharpPlus.
|
||||
Full Usage:
List.cycle lst
Parameters:
'b list
Returns: 'b list
|
|||||
Full Usage:
List.deleteAt i lst
Parameters:
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.
|
Use List.removeAt from FSharp.Core if you want to throw exceptions when using invalid indexes.
|
||||
Full Usage:
List.drop count source
Parameters:
int
-
The number of items to drop.
source : 'T list
-
The input list.
Returns: 'T list
The result list.
|
When count exceeds the number of elements in the list it returns an empty list instead of throwing an exception.
|
||||
Full Usage:
List.findLastSliceIndex slice source
Parameters:
'b list
source : 'b list
Returns: int
The index of the slice.
|
|
||||
Full Usage:
List.findSliceIndex slice source
Parameters:
'b list
source : 'b list
Returns: int
The index of the slice.
|
|
||||
Full Usage:
List.intercalate separator source
Parameters:
'T list
source : 'T list seq
Returns: 'T list
|
|||||
Full Usage:
List.intersperse separator source
Parameters:
'T
source : 'T list
Returns: 'T list
|
|||||
Full Usage:
List.lift2 f x1 x2
Parameters:
'T1 -> 'T2 -> 'U
x1 : 'T1 list
x2 : 'T2 list
Returns: 'U list
|
|||||
Full Usage:
List.lift3 f x1 x2 x3
Parameters:
'T1 -> 'T2 -> 'T3 -> 'U
-
Mapping function taking three element combination as input.
x1 : 'T1 list
-
First list.
x2 : 'T2 list
-
Second list.
x3 : 'T3 list
-
Third list.
Returns: 'U list
List with values returned from mapping function.
|
|
||||
Full Usage:
List.map2Shortest mapping list1 list2
Parameters:
'T1 -> 'T2 -> 'U
-
Mapping function.
list1 : 'T1 list
-
First input list.
list2 : 'T2 list
-
Second input list.
Returns: 'U list
List with corresponding results of applying the mapping function pairwise over both input lists elments.
|
|
||||
Full Usage:
List.map3Shortest mapping list1 list2 list3
Parameters:
'T1 -> 'T2 -> 'T3 -> 'U
list1 : 'T1 list
list2 : 'T2 list
list3 : 'T3 list
Returns: 'U list
|
|
||||
Full Usage:
List.partitionMap mapping source
Parameters:
'T -> Choice<'T1, 'T2>
source : 'T list
Returns: 'T1 list * 'T2 list
A tuple with both resulting lists.
|
|
||||
Full Usage:
List.replace oldValue newValue source
Parameters:
'T seq
newValue : 'T list
source : 'T list
Returns: 'T list
|
|||||
Full Usage:
List.setAt i x lst
Parameters:
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
|
|||||
Full Usage:
List.singleton value
Parameters:
'T
-
The input item.
Returns: 'T list
The result list of one item.
|
Note: this function has since been added to FSharp.Core. It will be removed in next major release of FSharpPlus.
Example
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val singleton: value: 'T -> 'T list
Evaluates to [ 7 ] .
|
||||
Full Usage:
List.skip count list
Parameters:
int
-
The number of elements to skip. If the number is 0 or negative the input list is returned.
list : 'T list
-
The input list.
Returns: 'T list
The list after removing the first N elements.
|
Note: this function has since been added to FSharp.Core. It will be removed in next major release of FSharpPlus.
Example
val inputs: string list
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val skip: count: int -> list: 'T list -> 'T list
Evaluates to ["c"; "d"]
Example
val inputs: string list
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val skip: count: int -> list: 'T list -> 'T list
Throws ArgumentException .
Example
val inputs: string list
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val skip: count: int -> list: 'T list -> 'T list
Evaluates to ["a"; "b"; "c"; "d"] .
|
||||
Full Usage:
List.split separators source
Parameters:
'a list seq
source : 'a list
Returns: 'a list seq
|
|||||
Full Usage:
List.tails list
Parameters:
'T list
Returns: 'T list list
|
|||||
Full Usage:
List.take count list
Parameters:
int
-
The number of items to take.
list : 'T list
-
The input list.
Returns: 'T list
The result list.
|
Throws
Example
val inputs: string list
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val take: count: int -> list: 'T list -> 'T list
Evaluates to ["a"; "b"]
Example
val inputs: string list
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val take: count: int -> list: 'T list -> 'T list
Throws InvalidOperationException .
Example
val inputs: string list
Multiple items
module List from Microsoft.FSharp.Collections -------------------- type List<'T> = | op_Nil | op_ColonColon of Head: 'T * Tail: 'T list interface IReadOnlyList<'T> interface IReadOnlyCollection<'T> interface IEnumerable interface IEnumerable<'T> member GetReverseIndex: rank: int * offset: int -> int member GetSlice: startIndex: int option * endIndex: int option -> 'T list static member Cons: head: 'T * tail: 'T list -> 'T list member Head: 'T member IsEmpty: bool member Item: index: int -> 'T with get ... val take: count: int -> list: 'T list -> 'T list
Evaluates to the empty list.
|
||||
Full Usage:
List.toIReadOnlyList source
Parameters:
'a list
-
The list source
Returns: IReadOnlyList<'a>
The list converted to a System.Collections.Generic.IReadOnlyList
|
|
||||
Full Usage:
List.tryFindLastSliceIndex slice source
Parameters:
'b list
source : 'b list
Returns: int option
The index of the slice or None .
|
|||||
Full Usage:
List.tryFindSliceIndex slice source
Parameters:
'b list
source : 'b list
Returns: int option
The index of the slice or None .
|
|||||
Full Usage:
List.zipShortest list1 list2
Parameters:
'T1 list
-
First input list.
list2 : 'T2 list
-
Second input list.
Returns: ('T1 * 'T2) list
List with corresponding pairs of input lists.
|