AutoOpenArrayTExtensions Module
Extension methods for Array<'T>. Like .Last , .IsNotEmpty ,.. This module is automatically opened when the namespace ArrayT is opened.
Type extensions
| Type extension |
Description
|
||
Full Usage:
this.AsString
Parameters:
unit
Returns: string
A formatted string representation of the array.
Modifiers: inline |
A string representation of the Array including the count of entries and the first 5 entries. This member is inlined so that the type name can be resolved by reflection in Fable too.
Extended Type:
|
||
Full Usage:
this.Copy
Parameters:
unit
Returns: 'T array
Modifiers: inline |
Creates a new Array with the same items as the input Array. Shallow copy only. Same as Array.copy. (The built-in arr.Clone() does the same but returns obj.)
Extended Type:
|
||
|
Use for Debugging index get/set operations. Just replace 'myArray.[3]' with 'myArray.DebugIdx.[3]' Throws a nice descriptive Exception if the index is out of range including the bad index and the array content.
Extended Type:
|
||
Full Usage:
this.FailIfEmpty
Parameters:
string
-
The error message to include in the exception.
Returns: 'T[]
The input Array if not empty.
Modifiers: inline |
Raises an ArrayTArgumentException if the Array is empty (Useful for chaining) Returns the input Array
Extended Type:
|
||
Full Usage:
this.FailIfLessThan
Parameters:
int
-
The minimum count required.
errorMessage : string
-
The error message to include in the exception.
Returns: 'T[]
The input Array if it has enough items.
Modifiers: inline |
Raises an ArrayTArgumentException if the Array has less than count items. (Useful for chaining) Returns the input Array
Extended Type:
|
||
Full Usage:
this.First
Parameters:
unit
Returns: 'T
Modifiers: inline |
Get (or set) the first item in the Array. Equal to this.[0]
Extended Type:
|
||
Full Usage:
this.FirstAndOnly
Parameters:
unit
Returns: 'T
Modifiers: inline |
Gets the only item in the Array. Fails if the Array does not have exactly one element.
Extended Type:
|
||
Full Usage:
this.Get
Parameters:
int
-
The index to access.
Returns: 'T
The value at the specified index.
Modifiers: inline |
Gets an item at index, same as this.[index] or this.Idx(index) Throws a descriptive Exception if the index is out of range including the bad index and the Array content. (Use this.GetNeg(i) member if you want to use negative indices too)
Extended Type:
|
||
Full Usage:
this.GetLooped
Parameters:
int
-
The index to access (can be any integer).
Returns: 'T
The value at the looped index.
Modifiers: inline |
Any index will return a value. Array is treated as an endless loop in positive and negative direction
Extended Type:
|
||
Full Usage:
this.GetNeg
Parameters:
int
-
The index to access (can be negative).
Returns: 'T
The value at the specified index.
Modifiers: inline |
Gets an item in the Array by index. Allows for negative index too ( -1 is last item, like Python) (With LangVersion preview, F# also supports indexing from the end with the '^' prefix, e.g. xs.[^0] for the last item.)
Extended Type:
|
||
Full Usage:
this.HasItems
Parameters:
unit
Returns: bool
Modifiers: inline |
Checks if this.Length > 0 Same as xs.IsNotEmpty. Unlike Array.hasItems, this property does not test for an exact count.
Extended Type:
|
||
Full Usage:
this.Idx
Parameters:
int
-
The index to access.
Returns: 'T
The value at the specified index.
Modifiers: inline |
Gets an item at index, same as this.[index] or this.Get(index) Throws a descriptive Exception if the index is out of range. (Use this.GetNeg(i) member if you want to use negative indices too)
Extended Type:
|
||
Full Usage:
this.IsEmpty
Parameters:
unit
Returns: bool
Modifiers: inline |
Checks if this.Length = 0
Extended Type:
|
||
Full Usage:
this.IsNotEmpty
Parameters:
unit
Returns: bool
Modifiers: inline |
Checks if this.Length > 0 Same as xs.HasItems
Extended Type:
|
||
Full Usage:
this.IsSingleton
Parameters:
unit
Returns: bool
Modifiers: inline |
Checks if this.Length = 1
Extended Type:
|
||
Full Usage:
this.Last
Parameters:
unit
Returns: 'T
Modifiers: inline |
Get (or set) the last item in the Array. Equal to this.[this.Length - 1]
Extended Type:
|
||
Full Usage:
this.LastIndex
Parameters:
unit
Returns: int
Modifiers: inline |
Gets the index of the last item in the Array. Equal to this.Length - 1 Returns -1 for empty Array.
Extended Type:
|
||
Full Usage:
this.Second
Parameters:
unit
Returns: 'T
Modifiers: inline |
Get (or set) the second item in the Array. Equal to this.[1]
Extended Type:
|
||
Full Usage:
this.SecondLast
Parameters:
unit
Returns: 'T
Modifiers: inline |
Get (or set) the second last item in the Array. Equal to this.[this.Length - 2]
Extended Type:
|
||
Full Usage:
this.Set
Parameters:
int
-
The index to set.
value : 'T
-
The value to set.
Modifiers: inline |
Sets an item at index (Use this.SetNeg(i) member if you want to use negative indices too)
Extended Type:
|
||
Full Usage:
this.SetLooped
Parameters:
int
-
The index to set (can be any integer).
value : 'T
-
The value to set.
Modifiers: inline |
Any index will set a value. Array is treated as an endless loop in positive and negative direction
Extended Type:
|
||
Full Usage:
this.SetNeg
Parameters:
int
-
The index to set (can be negative).
value : 'T
-
The value to set.
Modifiers: inline |
Sets an item in the Array by index. Allows for negative index too ( -1 is last item, like Python) (With LangVersion preview, F# also supports indexing from the end with the '^' prefix, e.g. xs.[^0] for the last item.)
Extended Type:
|
||
Full Usage:
this.SliceIdx
Parameters:
int
-
The inclusive start index of the slice.
endIdx : int
-
The inclusive end index of the slice.
Returns: 'T[]
A new array containing the requested range.
|
Returns a new array containing the elements between the specified inclusive start and end indices. This member rejects negative and out-of-bounds indices, while the F# slicing notation xs.[1..3] does not. To allow negative indices use SliceNeg, to normalize any index with modulo use SliceLooped.
Extended Type:
|
||
Full Usage:
this.SliceLooped
Parameters:
int
-
The inclusive start index to normalize.
endIdx : int
-
The inclusive end index to normalize.
Returns: 'T[]
A new array containing the requested range.
|
Returns a new array containing the elements between the specified start and end indices after normalizing both indices with modulo. Both indices are inclusive, and negative and out-of-range indices are allowed. If the normalized start index is greater than the normalized end index, an empty array is returned. For an empty input array, an empty array is returned.
Extended Type:
|
||
Full Usage:
this.SliceNeg
Parameters:
int
-
The start index (inclusive, can be negative).
endIdx : int
-
The end index (inclusive, can be negative).
Returns: 'T array
A new array containing the sliced elements.
|
Allows for negative indices too. ( -1 is last item, like Python) The resulting array includes the end index. If the end index is one less than the start index an empty array is returned. The built in slicing notation (e.g. a.[1..3]) for arrays does not allow for negative indices. (and can't be overwritten) To reject negative indices use SliceIdx, to normalize any index with modulo use SliceLooped. Alternative: with LangVersion preview, F# also supports slicing from the end with the '^' prefix, e.g. xs.[1..^1] skips the first and last item.
Extended Type:
|
||
Full Usage:
this.Third
Parameters:
unit
Returns: 'T
Modifiers: inline |
Get (or set) the third item in the Array. Equal to this.[2]
Extended Type:
|
||
Full Usage:
this.ThirdLast
Parameters:
unit
Returns: 'T
Modifiers: inline |
Get (or set) the third last item in the Array. Equal to this.[this.Length - 3]
Extended Type:
|
||
Full Usage:
this.ToString
Parameters:
int
-
The number of entries to display in the string representation.
Returns: string
A formatted string representation of the array.
Modifiers: inline |
A string representation of the Array including the count of entries and the specified amount of entries. This member is inlined so that the type name can be resolved by reflection in Fable too.
Extended Type:
|
ArrayT