
ArrayT
ArrayT is an F# extension and module library for Array<'T>
It also works in Javascript and Typescript with Fable.
Motivation
I was always annoyed that an IndexOutOfRangeException does not include the actual index that was out of bounds nor the actual size of the array.
This library fixes that in array.Get, array.Set, array.SliceNeg and other item access functions.
That was the initial motivation for creating this library.
It became a more general library for safer and more convenient array manipulation in F#.
This library was designed for use with F# scripting.
Functions and methods never return null.
Only functions starting with try... will return an F# Option.
When ArrayT rejects invalid input, it throws a descriptive exception such as ArrayTArgumentException, ArrayTArgumentNullException, or ArrayTKeyNotFoundException.
Each type inherits from its corresponding .NET exception type, so existing .NET exception handlers still work. Index errors use IndexOutOfRangeException directly because that type is sealed.
See also https://github.com/goswinr/ResizeArray/ for a similar library for ResizeArray<'T>.
It Includes
-
An
Arraymodule that adds functions to theArraymodule fromFSharp.Core.
See docs -
Extension members on
Arraylike
.Get idx.Set idx item.First.Last.SecondLastxs.DebugIdx.[i]and more..
With nicerIndexOutOfRangeExceptionmessages that include the bad index and the actual size.
See docs
Full API Documentation
Usage
Just open the namespace
open ArrayT
this namespace contains:
a module also called
Array. It will add additional functions to theArraymodule fromFSharp.Core.this will also auto open the extension members on
Array<'T>
Examples
Better error messages
The core motivation: descriptive exceptions when accessing out-of-range indices.
#r "nuget: ArrayT"
open ArrayT
let xs = [| 0 .. 88 |]
xs.Get(99)
throws
|
instead of the usual unhelpful System.IndexOutOfRangeException: Index was outside the bounds of the array.
The same applies to Set:
xs.Set 99 0
// throws: Array.Set: Can't set index 99 to 0 on:
// array<Int32> with 89 items: ...
If you want to use bracket notation xs.[i] with these descriptive errors, use the DebugIdx member:
let item = xs.DebugIdx.[99] // throws with same descriptive message
xs.DebugIdx.[99] <- 0 // setter also has descriptive errors
Positional access
Convenient properties for accessing items at common positions:
let arr = [| "a"; "b"; "c"; "d"; "e" |]
arr.First // "a"
arr.Second // "b"
arr.Third // "c"
arr.Last // "e"
arr.SecondLast // "d"
arr.ThirdLast // "c"
// These are settable too
arr.Last <- "z" // arr is now [| "a"; "b"; "c"; "d"; "z" |]
// For single-element arrays
let single = [| 42 |]
single.FirstAndOnly // 42
Or via module functions for use in pipelines:
[| 10; 20; 30 |] |> Array.first // 10
[| 10; 20; 30 |] |> Array.last // 30
[| 10; 20; 30 |] |> Array.secondLast // 20
Negative indexing (Python-style)
Use negative indices where -1 is the last item, -2 the second last, and so on:
let arr = [| "a"; "b"; "c"; "d"; "e" |]
arr.GetNeg(-1) // "e" (last)
arr.GetNeg(-2) // "d" (second last)
arr.SetNeg -1 "z"
// Module functions
arr |> Array.getNeg -1 // "e"
arr |> Array.setNeg -2 "x"
Looped indexing
Treats the array as circular, wrapping around in both directions:
let arr = [| "a"; "b"; "c" |]
arr.GetLooped(3) // "a" (wraps around)
arr.GetLooped(4) // "b"
arr.GetLooped(-1) // "c" (wraps backward)
arr.GetLooped(-4) // "c"
Slicing with negative indices
Unlike the built-in a.[1..3] slice syntax, SliceNeg supports negative indices:
let arr = [| 0; 1; 2; 3; 4; 5; 6; 7; 8; 9 |]
arr.SliceNeg(2, 5) // [| 2; 3; 4; 5 |] (inclusive on both ends)
arr.SliceNeg(0, -1) // [| 0; 1; .. ; 9 |] (full copy, -1 = last)
arr.SliceNeg(1, -2) // [| 1; 2; .. ; 8 |] (skip first and last)
arr.SliceNeg(-3, -1) // [| 7; 8; 9 |] (last 3 items)
// Module function
arr |> Array.sliceNeg 1 -2 // [| 1; 2; .. ; 8 |]
(arr.Slice and Array.slice still work, but are obsolete: in .NET the .Slice method of some collections, like List<'T> and Span<'T>, takes a start index and a length.
For a start index and a length use Array.sub.)
SliceIdx rejects negative indices, SliceLooped wraps any index around with modulo:
arr.SliceIdx(2, 5) // [| 2; 3; 4; 5 |]
arr.SliceIdx(-3, -1) // throws IndexOutOfRangeException
arr.SliceLooped(-3, -1) // [| 7; 8; 9 |]
arr.SliceLooped(10, 12) // [| 0; 1; 2 |] (10 wraps to 0, 12 to 2)
arr.SliceLooped(8, 11) // [||] (11 wraps to 1, which is before 8)
// Module functions
arr |> Array.sliceIdx 2 5
arr |> Array.sliceLooped -3 -1
Grouping into a dictionary
Array.groupByDict uses F# structural equality for grouping and dictionary lookups on both .NET and Fable.
Keys must support equality ('Key : equality); null and None keys are rejected. Elements within each group keep their input order.
let groups = [|1; 2; 3; 4; 5|] |> Array.groupByDict (fun x -> [|x % 2|])
groups.[[|1|]] // [|1; 3; 5|], looked up using a fresh, structurally equal array key
Trimming
Remove items from the start and end:
let arr = [| 0; 1; 2; 3; 4; 5 |]
arr |> Array.trim 1 1 // [| 1; 2; 3; 4 |] (trim 1 from each end)
arr |> Array.trim 2 0 // [| 2; 3; 4; 5 |] (trim 2 from start)
Rotating
Shift elements circularly:
let arr = [| 1; 2; 3; 4; 5 |]
arr |> Array.rotate 1 // [| 5; 1; 2; 3; 4 |] (rotate up by 1)
arr |> Array.rotate -1 // [| 2; 3; 4; 5; 1 |] (rotate down by 1)
arr |> Array.rotate 2 // [| 4; 5; 1; 2; 3 |] (rotate up by 2)
// Rotate until a condition is met
[| 3; 1; 4; 1; 5 |] |> Array.rotateUpTill (fun x -> x = 5)
// [| 5; 3; 1; 4; 1 |]
Windowed pairs and triples
Iterate over consecutive elements:
let arr = [| "a"; "b"; "c"; "d" |]
// Consecutive pairs (not looped, result is 1 shorter)
arr |> Array.windowed2
// seq { ("a","b"); ("b","c"); ("c","d") }
// Looped pairs (includes wrap-around, same length as input)
arr |> Array.thisNext
// seq { ("a","b"); ("b","c"); ("c","d"); ("d","a") }
arr |> Array.prevThis
// seq { ("d","a"); ("a","b"); ("b","c"); ("c","d") }
// Consecutive triples (not looped, result is 2 shorter)
arr |> Array.windowed3
// seq { ("a","b","c"); ("b","c","d") }
// Looped triples (same length as input)
arr |> Array.prevThisNext
// seq { ("d","a","b"); ("a","b","c"); ("b","c","d"); ("c","d","a") }
With indices:
let arr = [| 10; 20; 30; 40 |]
arr |> Array.windowed2i
// seq { (0, 10, 20); (1, 20, 30); (2, 30, 40) }
arr |> Array.iThisNext
// seq { (0, 10, 20); (1, 20, 30); (2, 30, 40); (3, 40, 10) }
Min and max (top 2 and top 3)
Find the smallest or largest elements:
let arr = [| 5; 1; 9; 3; 7 |]
Array.min2 arr // (1, 3) smallest and second smallest
Array.max2 arr // (9, 7) biggest and second biggest
Array.min3 arr // (1, 3, 5)
Array.max3 arr // (9, 7, 5)
// By projection
let words = [| "hi"; "hello"; "hey" |]
Array.min2By String.length words // ("hi", "hey")
Array.max2By String.length words // ("hello", "hey")
// Get indices instead of values
Array.min2IndicesBy String.length words // (0, 2)
Array.max2IndicesBy String.length words // (1, 2)
Finding duplicates
Array.duplicates [| 1; 2; 3; 2; 4; 3 |]
// [| 2; 3 |] (each duplicate reported once, ordered by where it repeats)
Array.duplicatesBy String.length [| "hi"; "hey"; "go"; "bye" |]
// [| "go"; "bye" |] (the items where length 2 and length 3 repeat)
Partitioning
let small, medium, large =
[| 1; 15; 150; 7; 70 |] |> Array.partition3 (fun x -> x < 10) (fun x -> x < 100)
// [| 1; 7 |], [| 15; 70 |], [| 150 |] (each item goes to the first predicate that is true)
// With different result types:
let numbers, words =
[| "1"; "a"; "2" |]
|> Array.partitionBy (fun s -> match Int32.TryParse s with | true, i -> Choice1Of2 i | _ -> Choice2Of2 s)
// [| 1; 2 |], [| "a" |]
partition4, partition5, partition3By, partition4By and partition5By work the same way.
Searching
let arr = [| 10; 20; 30; 40; 50 |]
Array.findValue 30 0 4 arr // 2 (found at index 2)
Array.findValue 99 0 4 arr // -1 (not found)
Array.findLastValue 30 0 4 arr // 2 (search from end)
// Search for sub-array pattern
let hay = [| 1; 2; 3; 4; 5; 3; 4 |]
Array.findArray [| 3; 4 |] 0 6 hay // 2 (first match)
Array.findLastArray [| 3; 4 |] 0 6 hay // 5 (last match)
Array checks
let arr = [| 1; 2; 3 |]
arr.IsEmpty // false
arr.IsNotEmpty // true
arr.HasItems // true (same as IsNotEmpty)
arr.IsSingleton // false
// Module functions
arr |> Array.isNotEmpty // true
arr |> Array.isSingleton // false
arr |> Array.hasItems 3 // true (exactly 3 items)
arr |> Array.hasMinimumItems 2 // true (at least 2 items)
arr |> Array.hasMaximumItems 5 // true (at most 5 items)
arr |> Array.count // 3
arr |> Array.countIf (fun x -> x > 1) // 2
Validation
Chainable validation methods for defensive programming:
let result =
someArray
|> Array.failIfEmpty "Input array must not be empty"
|> Array.failIfLessThan 3 "Need at least 3 elements"
|> Array.map doSomething
// Extension member versions
someArray
.FailIfEmpty("Input must not be empty")
.FailIfLessThan(3, "Need at least 3 elements")
Swapping
let arr = [| "a"; "b"; "c"; "d" |]
Array.swap 0 3 arr
// arr is now [| "d"; "b"; "c"; "a" |]
String representation
let arr = [| 1; 2; 3; 4; 5; 6; 7 |]
arr.AsString
// "array<Int32> with 7 items:
// 0: 1
// 1: 2
// 2: 3
// 3: 4
// 4: 5
// ...
// 6: 7"
arr.ToString(3) // show only first 3 entries (and the last one)
// "array<Int32> with 7 items:
// 0: 1
// 1: 2
// 2: 3
// ...
// 6: 7"
Skipping index checks in Fable
When compiling with Fable you can define the UNCHECKED symbol, e.g. dotnet fable --define UNCHECKED.
Then xs.Get, xs.Set, xs.Idx, Array.get and Array.set skip their index checks (and Array.get and Array.set their null checks too)
and compile to plain JavaScript arr[i] access.
Array.zeroCreateUndef then emits new Array(len) without filling the items with default values.
It is only available for reference types.
This works because Fable compiles ArrayT from source.
On .NET the precompiled ArrayT.dll from NuGet is used, so UNCHECKED has no effect there.
Use of AI and LLMs
All core functions are written by hand to ensure performance and correctness.
However, AI tools have been used for code review, typo and grammar checking in documentation
and to generate not all but many of the tests.
Tests
All Tests run in both javascript and dotnet. Successful Fable compilation to typescript is verified too. Go to the tests folder:
|
The tests use Scriptorium (Scriptorium.Quill + Scriptorium.Nib). The same test suite runs unchanged on .NET and on JS via Fable.
For testing with .NET:
|
for JS testing via Fable and TS verification:
|
License
Changelog
see CHANGELOG.md
<summary> 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. </summary>
val single: value: 'T -> single (requires member op_Explicit)
--------------------
type single = System.Single
--------------------
type single<'Measure> = float32<'Measure>
module Array from ArrayT
<summary> The main module for functions on Array<'T>. This module provides additional functions to ones from FSharp.Core.Array module. </summary>
--------------------
module Array from Microsoft.FSharp.Collections
<summary>Gets the first item in the Array. Same as this.[0]</summary>
<param name="arr">The input Array.</param>
<returns>The first item.</returns>
<summary>Gets the second last item in the Array. Same as this.[this.Length - 2]</summary>
<param name="arr">The input Array.</param>
<returns>The second last item.</returns>
<summary>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.)</summary>
<param name="index">The index to access (can be negative).</param>
<param name="arr">The input Array.</param>
<returns>The value at the specified index.</returns>
<summary>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.)</summary>
<param name="index">The index to set (can be negative).</param>
<param name="value">The value to set.</param>
<param name="arr">The input Array.</param>
<summary>Slice the Array given start and end index. 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. Raises an IndexOutOfRangeException if indices are out of range. If you don't want an exception to be raised for index overflow or overlap use Array.trim. To reject negative indices use Array.sliceIdx, to normalize any index with modulo use Array.sliceLooped. (With LangVersion preview, F# also supports slicing from the end with the '^' prefix, e.g. xs.[1..^1] skips the first and last item.)</summary>
<param name="startIdx">The start index (inclusive, can be negative).</param>
<param name="endIdx">The end index (inclusive, can be negative).</param>
<param name="arr">The input Array.</param>
<returns>A new array containing the sliced elements.</returns>
<exception cref="T:System.IndexOutOfRangeException">Thrown when either index is out of range or the start index is after the end index.</exception>
<summary>Returns a new Array containing the elements between the specified inclusive start and end indices. This function rejects negative and out-of-bounds indices, while the F# slicing notation xs.[1..3] does not. To allow negative indices use Array.sliceNeg, to normalize any index with modulo use Array.sliceLooped.</summary>
<param name="startIdx">The inclusive start index of the slice.</param>
<param name="endIdx">The inclusive end index of the slice.</param>
<param name="arr">The input Array.</param>
<returns>A new Array containing the requested range.</returns>
<exception cref="T:System.IndexOutOfRangeException">Thrown when either index is outside the Array or startIdx is greater than endIdx.</exception>
<summary>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.</summary>
<param name="startIdx">The inclusive start index to normalize.</param>
<param name="endIdx">The inclusive end index to normalize.</param>
<param name="arr">The input Array.</param>
<returns>A new Array containing the requested range.</returns>
<summary>Applies a key-generating function to each element of an Array and yields a Dictionary of unique keys and respective elements that match to this key. Uses F# structural equality for grouping and dictionary lookups on both .NET and Fable. Keys must support equality. Element order within each group is preserved. As opposed to Array.groupBy the key may not be null or Option.None.</summary>
<param name="projection">A function that transforms an element of the Array into a key supporting equality. Null and Option.None keys are rejected.</param>
<param name="arr">The input Array.</param>
<returns>A Dictionary containing each unique key and an Array of its matching elements.</returns>
<exception cref="T:ArrayT.ArrayTArgumentNullException">Thrown when the input Array is null or a projected key is null or Option.None.</exception>
<summary>Trim items from start and end. If the sum of fromStartCount and fromEndCount is equal to or greater than arr.Length, it returns an empty Array. If you want an exception to be raised for index overlap (total trimming is bigger than count) use Array.sliceNeg with a negative end index.</summary>
<param name="fromStartCount">The number of items to remove from the start.</param>
<param name="fromEndCount">The number of items to remove from the end.</param>
<param name="arr">The input Array.</param>
<returns>A new trimmed array.</returns>
<summary>Considers array circular and move elements up for positive integers or down for negative integers. e.g.: rotate +1 [ a, b, c, d] = [ d, a, b, c] e.g.: rotate -1 [ a, b, c, d] = [ b, c, d, a] the amount can even be bigger than the array's size. I will just rotate more than one loop.</summary>
<param name="amount">How many elements to shift forward. Or backward if number is negative</param>
<param name="arr">The input Array.</param>
<returns>The new result Array.</returns>
<summary>Considers array circular and move elements up till condition is met for the first item. The algorithm takes elements from the end and put them at the start till the first element in the array meets the condition. If the first element in the input meets the condition no changes are made. But still a shallow copy is returned.</summary>
<param name="condition">The condition to meet.</param>
<param name="arr">The input Array.</param>
<returns>The new result Array.</returns>
<summary>Yields Seq from (first, second) up to (second-last, last). Not looped. The resulting seq is one element shorter than the input Array.</summary>
<param name="arr">The input Array.</param>
<returns>A sequence of consecutive pairs.</returns>
<summary>Yields looped Seq from (first, second) up to (last, first). The resulting seq has the same element count as the input Array.</summary>
<param name="arr">The input Array.</param>
<returns>A sequence of consecutive pairs (looped).</returns>
<summary>Yields looped Seq from (last,first) up to (second-last, last). The resulting seq has the same element count as the input Array.</summary>
<param name="arr">The input Array.</param>
<returns>A sequence of consecutive pairs (looped).</returns>
<summary>Yields Seq from (first, second, third) up to (third-last, second-last, last). Not looped. The resulting seq is two elements shorter than the input Array.</summary>
<param name="arr">The input Array.</param>
<returns>A sequence of consecutive triples.</returns>
<summary>Yields looped Seq of from (last, first, second) up to (second-last, last, first). The resulting seq has the same element count as the input Array.</summary>
<param name="arr">The input Array.</param>
<returns>A sequence of consecutive triples (looped).</returns>
<summary>Yields Seq from (0,first, second) up to (lastIndex-1 , second-last, last). Not looped. The resulting seq is one element shorter than the input Array.</summary>
<param name="arr">The input Array.</param>
<returns>A sequence of consecutive indexed pairs.</returns>
<summary>Yields looped Seq from (0,first, second) up to (lastIndex, last, first). The resulting seq has the same element count as the input Array.</summary>
<param name="arr">The input Array.</param>
<returns>A sequence of indexed consecutive pairs (looped).</returns>
<summary>Returns the smallest and the second smallest element of the Array. If they are equal then the order is kept. NaN is ranked after all other values, so NaN is only returned if there are not enough other values.</summary>
<param name="arr">The input Array.</param>
<returns>A tuple of the smallest and second smallest elements.</returns>
<summary>Returns the biggest and the second biggest element of the Array. If they are equal then the order is kept. NaN is ranked after all other values, so NaN is only returned if there are not enough other values.</summary>
<param name="arr">The input Array.</param>
<returns>A tuple of the biggest and second biggest elements.</returns>
<summary>Returns the smallest three elements of the Array. The first element is the smallest, the second is the second smallest and the third is the third smallest. If they are equal then the order is kept. NaN is ranked after all other values, so NaN is only returned if there are not enough other values.</summary>
<param name="arr">The input Array.</param>
<returns>A tuple of the three smallest elements.</returns>
<summary>Returns the biggest three elements of the Array. The first element is the biggest, the second is the second biggest and the third is the third biggest. If they are equal then the order is kept. NaN is ranked after all other values, so NaN is only returned if there are not enough other values.</summary>
<param name="arr">The input Array.</param>
<returns>A tuple of the three biggest elements.</returns>
<summary>Returns the smallest and the second smallest element of the Array. Elements are compared by applying the predicate function first. If they are equal after function is applied then the order is kept. NaN keys are ranked after all other keys, so elements with a NaN key are only returned if there are not enough other elements.</summary>
<param name="f">The function to transform elements for comparison.</param>
<param name="arr">The input Array.</param>
<returns>A tuple of the smallest and second smallest elements.</returns>
<summary>Returns the biggest and the second biggest element of the Array. Elements are compared by applying the predicate function first. If they are equal after function is applied then the order is kept. NaN keys are ranked after all other keys, so elements with a NaN key are only returned if there are not enough other elements.</summary>
<param name="f">The function to transform elements for comparison.</param>
<param name="arr">The input Array.</param>
<returns>A tuple of the biggest and second biggest elements.</returns>
<summary>Returns the indices of the smallest and the second smallest element of the Array. Elements are compared by applying the predicate function first. If they are equal after function is applied then the order is kept. NaN keys are ranked after all other keys, so indices of NaN keys are only returned if there are not enough other keys.</summary>
<param name="f">The function to transform elements for comparison.</param>
<param name="arr">The input Array.</param>
<returns>A tuple of the indices of the smallest and second smallest elements.</returns>
<summary>Returns the indices of the biggest and the second biggest element of the Array. Elements are compared by applying the predicate function first. If they are equal after function is applied then the order is kept. NaN keys are ranked after all other keys, so indices of NaN keys are only returned if there are not enough other keys.</summary>
<param name="f">The function to transform elements for comparison.</param>
<param name="arr">The input Array.</param>
<returns>A tuple of the indices of the biggest and second biggest elements.</returns>
<summary>Returns all elements that exist more than once in Array. Each element that exists more than once is only returned once. The returned item is the second occurrence, where the duplicate is first detected. Returned order is by position of that second occurrence.</summary>
<param name="arr">The input Array.</param>
<returns>An array of duplicate elements.</returns>
<summary>Returns all elements whose projected value exists more than once in Array. Each projected value that exists more than once is only returned once. The returned item is the second occurrence, where the duplicate is first detected. Returned order is by position of that second occurrence.</summary>
<param name="f">The function to extract comparison value from each element.</param>
<param name="arr">The input Array.</param>
<returns>An array of duplicate elements.</returns>
<summary>Splits the collection into three collections, first containing the elements for which the given predicate1 returns <c>true</c>, second containing the elements for which the given predicate2 returns <c>true</c> (and all previous predicates returned <c>false</c>), third the rest.</summary>
<param name="predicate1">The first function to test the input elements.</param>
<param name="predicate2">The second function to test the input elements.</param>
<param name="arr">The input Array.</param>
<returns>Three Arrays.</returns>
<summary>Splits the collection into two collections, containing the elements for which the given function returns <c>Choice1Of2</c> or <c>Choice2Of2</c>, respectively. This function is similar to <c>Array.partition</c>, but it allows the returned collections to have different element types.</summary>
<param name="partitioner">The function to transform and classify each input element into one of two output types.</param>
<param name="arr">The input Array.</param>
<returns>A tuple of two Arrays. The first containing values from Choice1Of2 results and the second containing values from Choice2Of2 results.</returns>
<summary>Find first index where searchFor occurs in searchIn array. Give lower and upper bound index for search space. Returns -1 if not found</summary>
<param name="searchFor">The value to search for.</param>
<param name="fromIdx">The starting index for the search.</param>
<param name="tillIdx">The ending index for the search.</param>
<param name="searchIn">The array to search in.</param>
<returns>The index of the first occurrence, or -1 if not found.</returns>
<summary>Find last index where searchFor occurs in searchIn array. Searching from end. Give lower and upper bound index for search space. Returns -1 if not found</summary>
<param name="searchFor">The value to search for.</param>
<param name="fromIdx">The starting index for the search.</param>
<param name="tillIdx">The ending index for the search.</param>
<param name="searchIn">The array to search in.</param>
<returns>The index of the last occurrence, or -1 if not found.</returns>
<summary>Find first index where searchFor array occurs in searchIn array. Give lower and upper bound index for search space. Returns index of first element or -1 if not found</summary>
<param name="searchFor">The array pattern to search for.</param>
<param name="fromIdx">The starting index for the search.</param>
<param name="tillIdx">The ending index for the search.</param>
<param name="searchIn">The array to search in.</param>
<returns>The index of the first occurrence, or -1 if not found.</returns>
<summary>Find last index where searchFor array occurs in searchIn array. Searching from end. Give lower and upper bound index for search space. Returns index of first element or -1 if not found</summary>
<param name="searchFor">The array pattern to search for.</param>
<param name="fromIdx">The starting index for the search.</param>
<param name="tillIdx">The ending index for the search.</param>
<param name="searchIn">The array to search in.</param>
<returns>The index of the last occurrence, or -1 if not found.</returns>
<summary>Returns true if the given Array is not empty.</summary>
<param name="arr">The input Array.</param>
<returns>True if the Array has at least one item.</returns>
<summary>Returns true if the given Array has just one item. Same as Array.hasOne</summary>
<param name="arr">The input Array.</param>
<returns>True if the Array has exactly one item.</returns>
<summary>Returns true if the given Array has count items. Unlike the HasItems extension property, this function tests for an exact count.</summary>
<param name="count">The exact count to check for.</param>
<param name="arr">The input Array.</param>
<returns>True if the Array has exactly the specified count.</returns>
<summary>Returns true if the given Array has equal or more than count items.</summary>
<param name="count">The minimum count required.</param>
<param name="arr">The input Array.</param>
<returns>True if the Array has at least the specified count.</returns>
<summary>Returns true if the given Array has equal or less than count items.</summary>
<param name="count">The maximum count allowed.</param>
<param name="arr">The input Array.</param>
<returns>True if the Array has at most the specified count.</returns>
<summary>Return the length or count of the collection. Same as Array.length</summary>
<param name="arr">The input Array.</param>
<returns>The number of items in the Array.</returns>
<summary>Counts for how many items of the collection the predicate returns true. Same as Array.filter and then Array.length</summary>
<param name="predicate">The function to test each element.</param>
<param name="arr">The input Array.</param>
<returns>The count of items for which the predicate returns true.</returns>
<summary>Raises an ArrayTArgumentException if the Array is empty. (Useful for chaining) Returns the input Array</summary>
<param name="errorMessage">The error message to include in the exception.</param>
<param name="arr">The input Array.</param>
<returns>The input Array if not empty.</returns>
<summary>Raises an ArrayTArgumentException if the Array has less then count items. (Useful for chaining) Returns the input Array</summary>
<param name="count">The minimum count required.</param>
<param name="errorMessage">The error message to include in the exception.</param>
<param name="arr">The input Array.</param>
<returns>The input Array if it has enough items.</returns>
<summary>Swap the values of two given indices in Array</summary>
<param name="i">The first index to swap.</param>
<param name="j">The second index to swap.</param>
<param name="arr">The input Array.</param>
ArrayT