Logo GenPRES

List Module

Finds, replaces, removes and counts the elements of a list and builds the rotations and combinations of lists.

Functions and values

Function or value Description

List.collectLists p

Full Usage: List.collectLists p

Parameters:
    p : 'a -> bool

Returns: 'a list list -> 'a list
Type parameters: 'a
p : 'a -> bool
Returns: 'a list list -> 'a list

List.combinations xss

Full Usage: List.combinations xss

Parameters:
    xss : 'a list

Returns: 'b list list
Type parameters: 'a, 'b (requires :> 'b Microsoft.FSharp.Collections.seq)

Every combination of one element of each list, in order: no lists give one empty combination, and an empty list gives none.

xss : 'a list
Returns: 'b list list

List.countByList xs1 xs2

Full Usage: List.countByList xs1 xs2

Parameters:
    xs1 : string list
    xs2 : string list

Returns: (string * int) list
xs1 : string list
xs2 : string list
Returns: (string * int) list

List.distinct xs

Full Usage: List.distinct xs

Parameters:
    xs : 'a list

Returns: 'a list
Type parameters: 'a (requires equality)
xs : 'a list
Returns: 'a list

List.findNearestMax n ns

Full Usage: List.findNearestMax n ns

Parameters:
    n : ^a
    ns : ^a list

Returns: ^a
Modifiers: inline
Type parameters: ^a, 'b (requires comparison and (static member op_Subtraction : ^a * ^a -> 'b) and (static member op_Subtraction : ^a * ^a -> 'b) and comparison)
n : ^a
ns : ^a list
Returns: ^a

List.hasExactlyOne pred xs

Full Usage: List.hasExactlyOne pred xs

Parameters:
    pred : 'a -> bool
    xs : 'a list

Returns: bool
Type parameters: 'a
pred : 'a -> bool
xs : 'a list
Returns: bool

List.headTail xs

Full Usage: List.headTail xs

Parameters:
    xs : 'a list

Returns: 'a option * 'a option
Type parameters: 'a
xs : 'a list
Returns: 'a option * 'a option

List.isConsecutive zero diff xs

Full Usage: List.isConsecutive zero diff xs

Parameters:
    zero : ^a
    diff : 'b
    xs : ^a list

Returns: bool
Modifiers: inline
Type parameters: ^a, 'b (requires comparison and (static member op_Subtraction : ^a * ^a -> 'b) and equality)
zero : ^a
diff : 'b
xs : ^a list
Returns: bool

List.listFilter p

Full Usage: List.listFilter p

Parameters:
    p : 'a -> bool

Returns: 'a list list -> 'a list list
Type parameters: 'a

filter a list of lists

p : 'a -> bool
Returns: 'a list list -> 'a list list

List.pickList pl xs

Full Usage: List.pickList pl xs

Parameters:
    pl : int list
    xs : List<'a>

Returns: List<'a>
Type parameters: 'a
pl : int list
xs : List<'a>
Returns: List<'a>

List.pos_ i

Full Usage: List.pos_ i

Parameters:
    i : int

Returns: Prism<'v list, 'v>
Type parameters: 'v

Prism onto the element at index i of a list: getOpt returns it when the list is long enough, set replaces it in place and is a no-op otherwise. Matches Aether's Optics.List.pos_, which the ZForm optics compose onto.

i : int
Returns: Prism<'v list, 'v>

List.prepend xs1 xs2

Full Usage: List.prepend xs1 xs2

Parameters:
    xs1 : 'a list
    xs2 : 'a list

Returns: 'a list
Type parameters: 'a

Concatenates two lists, placing the elements of xs2 before the elements of xs1. /// Example: [1;2] |> prepend [3;4] = [1;2;3;4]

xs1 : 'a list
xs2 : 'a list
Returns: 'a list

List.remove pred xs

Full Usage: List.remove pred xs

Parameters:
    pred : 'a -> bool
    xs : 'a list

Returns: 'a list
Type parameters: 'a

In summary, the remove function removes the first element in the list that satisfies the given predicate, while keeping the order of the other elements intact. If no element satisfying the predicate is found, the original list is returned unchanged.

pred : 'a -> bool
xs : 'a list
Returns: 'a list

List.removeDuplicates xs

Full Usage: List.removeDuplicates xs

Parameters:
    xs : 'a list

Returns: 'a list
Type parameters: 'a (requires equality)
xs : 'a list
Returns: 'a list

List.removeFirst pred

Full Usage: List.removeFirst pred

Parameters:
    pred : 'a -> bool

Returns: 'a list -> 'a list
Type parameters: 'a
pred : 'a -> bool
Returns: 'a list -> 'a list

List.replace pred x xs

Full Usage: List.replace pred x xs

Parameters:
    pred : 'a -> bool
    x : 'a
    xs : 'a list

Returns: 'a list
Type parameters: 'a

Replace an element x in a list xs when the pred function returns true. Note: will only replace the *first* element that satisfies the condition in pred Example: [1;2;3;2] |> replace (fun x -> x = 2) 4 = [1;4;3;2]

pred : 'a -> bool
x : 'a
xs : 'a list
Returns: 'a list

List.replaceOrAdd pred x xs

Full Usage: List.replaceOrAdd pred x xs

Parameters:
    pred : 'a -> bool
    x : 'a
    xs : 'a list

Returns: 'a list
Type parameters: 'a
pred : 'a -> bool
x : 'a
xs : 'a list
Returns: 'a list

List.rotations xs

Full Usage: List.rotations xs

Parameters:
    xs : 'a list - The input list to rotate

Returns: 'a list list An array of lists containing all possible rotations
Type parameters: 'a

Generate all possible cyclic rotations of a list. Each rotation moves one element from its current position to the front, creating n different arrangements where n is the length of the list.

xs : 'a list

The input list to rotate

Returns: 'a list list

An array of lists containing all possible rotations

Example

 rotations [1; 2; 3]
 // Returns: [| [1; 2; 3]; [2; 1; 3]; [3; 1; 2] |]

 rotations ["A"; "B"]
 // Returns: [| ["A"; "B"]; ["B"; "A"] |]

 rotations [42]
 // Returns: [| [42] |]

 rotations []
 // Returns: [| |]

List.sequenceOption xs

Full Usage: List.sequenceOption xs

Parameters:
    xs : 'a option list

Returns: 'a list option
Type parameters: 'a

The values of the options when every option has a value; None when one has none.

xs : 'a option list
Returns: 'a list option

List.someIfOne _arg1

Full Usage: List.someIfOne _arg1

Parameters:
    _arg1 : 'a list

Returns: 'a option
Type parameters: 'a
_arg1 : 'a list
Returns: 'a option

List.toString xs

Full Usage: List.toString xs

Parameters:
    xs : 'a list

Returns: string
Modifiers: inline
Type parameters: 'a
xs : 'a list
Returns: string

List.toString2 xs

Full Usage: List.toString2 xs

Parameters:
    xs : 'a list

Returns: string
Modifiers: inline
Type parameters: 'a
xs : 'a list
Returns: string

List.tryFindFirst get n xs

Full Usage: List.tryFindFirst get n xs

Parameters:
    get : 'a -> 'b
    n : 'b
    xs : 'a list list

Returns: 'a option
Type parameters: 'a, 'b (requires equality)

Try to find the first element with n in a list of list xsl with a function get to get n from an element

get : 'a -> 'b
n : 'b
xs : 'a list list
Returns: 'a option

List.tryFindInList pred xs

Full Usage: List.tryFindInList pred xs

Parameters:
    pred : 'a -> bool
    xs : 'a list list

Returns: 'a option
Type parameters: 'a
pred : 'a -> bool
xs : 'a list list
Returns: 'a option

List.tryFindRest pred xs

Full Usage: List.tryFindRest pred xs

Parameters:
    pred : 'a -> bool
    xs : 'a list

Returns: 'a option * 'a list
Type parameters: 'a
pred : 'a -> bool
xs : 'a list
Returns: 'a option * 'a list

Type something to start searching.