Logo ArrayT

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

this.AsString

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: []

() : unit
Returns: string

A formatted string representation of the array.

this.Copy

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: []

() : unit
Returns: 'T array

this.DebugIdx

Full Usage: this.DebugIdx

Parameters:
    () : unit

Returns: DebugIndexer<'T>

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: []

() : unit
Returns: DebugIndexer<'T>

this.FailIfEmpty

Full Usage: this.FailIfEmpty

Parameters:
    errorMessage : 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: []

errorMessage : string

The error message to include in the exception.

Returns: 'T[]

The input Array if not empty.

this.FailIfLessThan

Full Usage: this.FailIfLessThan

Parameters:
    count : 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: []

count : 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.

this.First

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: []

() : unit
Returns: 'T

this.FirstAndOnly

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: []

() : unit
Returns: 'T

this.Get

Full Usage: this.Get

Parameters:
    index : 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: []

index : int

The index to access.

Returns: 'T

The value at the specified index.

this.GetLooped

Full Usage: this.GetLooped

Parameters:
    index : 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: []

index : int

The index to access (can be any integer).

Returns: 'T

The value at the looped index.

this.GetNeg

Full Usage: this.GetNeg

Parameters:
    index : 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: []

index : int

The index to access (can be negative).

Returns: 'T

The value at the specified index.

this.HasItems

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: []

() : unit
Returns: bool

this.Idx

Full Usage: this.Idx

Parameters:
    index : 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: []

index : int

The index to access.

Returns: 'T

The value at the specified index.

this.IsEmpty

Full Usage: this.IsEmpty

Parameters:
    () : unit

Returns: bool
Modifiers: inline

Checks if this.Length = 0

Extended Type: []

() : unit
Returns: bool

this.IsNotEmpty

Full Usage: this.IsNotEmpty

Parameters:
    () : unit

Returns: bool
Modifiers: inline

Checks if this.Length > 0 Same as xs.HasItems

Extended Type: []

() : unit
Returns: bool

this.IsSingleton

Full Usage: this.IsSingleton

Parameters:
    () : unit

Returns: bool
Modifiers: inline

Checks if this.Length = 1

Extended Type: []

() : unit
Returns: bool

this.Last

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: []

() : unit
Returns: 'T

this.LastIndex

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: []

() : unit
Returns: int

this.Second

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: []

() : unit
Returns: 'T

this.SecondLast

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: []

() : unit
Returns: 'T

this.Set

Full Usage: this.Set

Parameters:
    index : 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: []

index : int

The index to set.

value : 'T

The value to set.

this.SetLooped

Full Usage: this.SetLooped

Parameters:
    index : 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: []

index : int

The index to set (can be any integer).

value : 'T

The value to set.

this.SetNeg

Full Usage: this.SetNeg

Parameters:
    index : 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: []

index : int

The index to set (can be negative).

value : 'T

The value to set.

this.SliceIdx

Full Usage: this.SliceIdx

Parameters:
    startIdx : 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: []

startIdx : 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.

IndexOutOfRangeException Thrown when either index is outside the array or startIdx is greater than endIdx.

this.SliceLooped

Full Usage: this.SliceLooped

Parameters:
    startIdx : 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: []

startIdx : int

The inclusive start index to normalize.

endIdx : int

The inclusive end index to normalize.

Returns: 'T[]

A new array containing the requested range.

this.SliceNeg

Full Usage: this.SliceNeg

Parameters:
    startIdx : 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: []

startIdx : 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.

IndexOutOfRangeException Thrown when either index is out of range or the start index is after the end index.

this.Third

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: []

() : unit
Returns: 'T

this.ThirdLast

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: []

() : unit
Returns: 'T

this.ToString

Full Usage: this.ToString

Parameters:
    entriesToPrint : 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: []

entriesToPrint : int

The number of entries to display in the string representation.

Returns: string

A formatted string representation of the array.

Type something to start searching.