Seq Module
Picks, filters, prunes and formats the elements of a sequence and tests whether all elements are equal or unique.
Nested modules
| Modules | Description |
|
Holds the Unquote tests of the Seq functions. |
Functions and values
| Function or value |
Description
|
Full Usage:
Seq.allEqualSeq succ fail xs
Parameters:
'a -> 'b
fail : 'b
xs : 'a seq
Returns: 'b
Type parameters: 'a, 'b (requires equality) |
Determine if all elements in a sequence are equal. Pass the distinct element to the succ function if all elements are equal, else return fail. Example: allEqualSeq (fun x -> Some x) (fun () -> None) seq {1;1;1} -> Some 1
|
Full Usage:
Seq.allEqualToOptSeq xs
Parameters:
'a seq
Returns: 'a option
Type parameters: 'a (requires equality) |
Return an option of an element if all elements in a sequence are equal or return None
|
Full Usage:
Seq.allEqualToStringSeq xs
Parameters:
'a seq
Returns: string
Type parameters: 'a (requires equality) |
Return the string version of an element if all elements in a sequence are equal or return an empty string Example: allEqualToStringSeq seq {1;1;1} -> "1"
|
Full Usage:
Seq.allUnique xs
Parameters:
'a seq
Returns: bool
Type parameters: 'a (requires comparison) |
Check if all elements in a sequence are unique Example: allUnique seq {1;2;3} -> true
|
Full Usage:
Seq.collectSeqs p xs
Parameters:
'a -> bool
xs : 'b seq
Returns: 'a seq
Type parameters: 'a, 'b (requires :> 'a Microsoft.FSharp.Collections.seq) |
In summary, the collectSeqs function filters the elements within each subsequence using the predicate function p and then combines the filtered elements from all subsequences into a single sequence, effectively flattening the subsequences while applying the filtering criterion. Example: collectSeqs (fun x -> x % 2 = 0) seq {seq {1;2;3}; seq {4;5;6}; seq {7;8;9}} -> seq {2;4;6;8}
|
Full Usage:
Seq.pickSeq pl xs
Parameters:
int list
xs : 'a seq
Returns: 'a seq
Type parameters: 'a |
Pick elements from a sequence using a list of indices pl
|
Full Usage:
Seq.prepend xs1 xs2
Parameters:
'a seq
xs2 : 'a seq
Returns: 'a seq
Type parameters: 'a |
Prepend a sequence to another sequence Example: seq {1;2} |> prepend {3;4} -> seq {1;2;3;4}
|
Full Usage:
Seq.pruneSeq maxLength xs
Parameters:
int
xs : 'a seq
Returns: 'a seq
Type parameters: 'a |
In summary, the pruneSeq function trims the input sequence xs by keeping its first and last elements, along with elements that are spaced out proportionally in between, such that the final length of the sequence doesn't exceed the specified maxLength. The spacing between the elements is controlled by the calculated step size d. Example: pruneSeq 5 seq {1;2;3;4;5;6;7;8;9} -> seq {1;4;7;9}
|
Full Usage:
Seq.seqFilter p xs
Parameters:
'a -> bool
xs : 'b seq
Returns: 'b seq
Type parameters: 'a, 'b (requires :> 'a Microsoft.FSharp.Collections.seq) |
Filter a sequence of sequences using a predicate function p. The purpose of this function is to filter the elements of the input sequence xs based on the condition that at least one element in each subsequence (inside xs) satisfies the predicate function p. Example: filterSeqs (fun x -> x % 2 = 0) seq {seq {1;3}; seq {4;5;6}; seq {7;8;9}} -> seq {seq {4;5;6}}
|
Full Usage:
Seq.someIfOneSeq xs
Parameters:
'a seq
Returns: 'a option
Type parameters: 'a |
Return an option of an element if the sequence contains exactly one element or return None
|
Full Usage:
Seq.toReadableString xs
Parameters:
'a seq
Returns: string
Modifiers: inline Type parameters: 'a |
Convert a sequence to a string using a left and right delimiter Left = empty string, right = empty string, del = ; Example: toReadableString [|1;2;3|] -> "1;2;3"
|
Full Usage:
Seq.toString xs
Parameters:
'a seq
Returns: string
Modifiers: inline Type parameters: 'a |
Convert a sequence to a string using a left and right delimiter left = [|, right = |], del = ; Example: toString [|1;2;3|] -> "[|1;2;3|]"
|
Full Usage:
Seq.toString_ left right del xs
Parameters:
string
right : string
del : 'a
xs : 'b seq
Returns: string
Modifiers: inline Type parameters: 'a, 'b |
Convert a sequence to a string using a left and right delimiter and a delimiter between elements. Example: toStringSeq "[|" "|]" ";" seq {1;2;3} -> "[|1;2;3|]"
|
GenPRES