Array Module
Picks, removes, prunes and formats the elements of an array and finds the median and the element nearest to a target.
Nested modules
| Modules | Description |
|
Holds the Unquote tests of the Array functions. |
Functions and values
| Function or value |
Description
|
Full Usage:
Array.allEqual succ fail xs
Parameters:
'a -> 'b
fail : 'b
xs : 'a[]
Returns: 'b
Type parameters: 'a, 'b (requires equality) |
Determine if all elements in an array are equal. Pass the distinct element to the succ function if all elements are equal, else return fail. Example: allEqual (fun x -> Some x) (fun () -> None) [|1;1;1|] -> Some 1
|
Full Usage:
Array.allEqualToOpt xs
Parameters:
'a[]
Returns: 'a option
Type parameters: 'a (requires equality) |
Return an option of an element if all elements in an array are equal or return None
|
Full Usage:
Array.allEqualToString xs
Parameters:
'a[]
Returns: string
Type parameters: 'a (requires equality) |
Return the string version of an element if all elements in an array are equal or return an empty string Example: allEqualToString [|1;1;1|] -> "1"
|
Full Usage:
Array.arrayFilter p xs
Parameters:
'a -> bool
xs : 'a array array
Returns: 'a array array
Type parameters: 'a |
Filter an array of arrays using a predicate function p. The purpose of this function is to filter the elements of the input array xs based on the condition that at least one element in each subarray (inside xs) satisfies the predicate function p. Example: filterArrays (fun x -> x % 2 = 0) [|[|1;3|]; [|4;5;6|]; [|7;8;9|]|] -> [|[|4;5;6|]|]
|
Full Usage:
Array.collectArrays p xs
Parameters:
'a -> bool
xs : 'a array array
Returns: 'a array
Type parameters: 'a |
In summary, the collectArrays function filters the elements within each subarray using the predicate function p and then combines the filtered elements from all subarrays into a single array, effectively flattening the subarrays while applying the filtering criterion. Example: collectArrays (fun x -> x % 2 = 0) [|[|1;2;3|]; [|4;5;6|]; [|7;8;9|]|] -> [|2;4;6;8|]
|
Full Usage:
Array.indices pred xs
Parameters:
'a -> bool
xs : 'a array
Returns: int array
Type parameters: 'a |
|
Full Usage:
Array.median xs
Parameters:
int array
Returns: float
|
|
Full Usage:
Array.nearestIndex x xs
Parameters:
^a
xs : ^b[]
Returns: int
Modifiers: inline Type parameters: ^a, ^b, ^c (requires (static member op_Subtraction : ^a * ^b -> ^c) and (static member op_Subtraction : ^a * ^b -> ^c) and (static member Abs : ^c -> ^c) and comparison) |
Get the nearest index in an array to a target value. Returns the index of the element that has the smallest absolute difference from the target. Throws an exception if the array is empty.
|
Full Usage:
Array.pickArray pl xs
Parameters:
int seq
xs : 'a[]
Returns: 'a[]
Type parameters: 'a |
Pick elements from an array using a list of indices pl0
|
Full Usage:
Array.pickNearestHigherElseLower target xs
Parameters:
'a
xs : 'a array
Returns: 'a
Modifiers: inline Type parameters: 'a (requires comparison) |
|
Full Usage:
Array.prepend xs1 xs2
Parameters:
'a array
xs2 : 'a array
Returns: 'a array
Type parameters: 'a |
Prepend an array to another array Example: [|1;2|] |> prepend [|3;4|] -> [|1;2;3;4|]
|
Full Usage:
Array.prune maxLength xs
Parameters:
int
xs : 'a array
Returns: 'a array
Type parameters: 'a |
In summary, the prune function trims the input array 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 array doesn't exceed the specified maxLength. The spacing between the elements is controlled by the calculated step size d. Example: prune 5 [|1;2;3;4;5;6;7;8;9|] -> [|1; 4; 7; 9|]
|
Full Usage:
Array.remove pred xs
Parameters:
'a -> bool
xs : 'a array
Returns: 'a array
Type parameters: 'a |
Remove elements from an array using a predicate function pred.
|
Full Usage:
Array.someIfOne _arg1
Parameters:
'a[]
Returns: 'a option
Type parameters: 'a |
Return an option of an element if the array contains exactly one element or return None
|
Full Usage:
Array.toReadableString xs
Parameters:
'a[]
Returns: string
Modifiers: inline Type parameters: 'a |
Convert an array 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:
Array.toString xs
Parameters:
'a[]
Returns: string
Modifiers: inline Type parameters: 'a |
Convert an array to a string using a left and right delimiter left = [|, right = |], del = ; Example: toString [|1;2;3|] -> "[|1;2;3|]"
|
Full Usage:
Array.toString_ left right del xs
Parameters:
string
right : string
del : 'a
xs : 'b[]
Returns: string
Modifiers: inline Type parameters: 'a, 'b |
Convert an array to a string using a left and right delimiter and a delimiter between elements. Example: toString_ "[|" "|]" ";" [|1;2;3|] -> "[|1;2;3|]"
|
GenPRES