Comment extension
The built-in Seq.last veryLongArrayName option Seq.last veryLongArrayName , but note that this is O (N), not O (1), so for all but the smallest arrays, it is probably too inefficient for practical use.
However, there is no harm in abstracting this functionality:
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] [<RequireQualifiedAccess>] module Array = let inline last (arr:_[]) = arr.[arr.Length - 1]
Now you can make Array.last veryLongArrayName without any overhead, while keeping the code very idiomatic and readable.
source share