FSharpCoreMissingParts 1.1.0

dotnet add package FSharpCoreMissingParts --version 1.1.0
                    
NuGet\Install-Package FSharpCoreMissingParts -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FSharpCoreMissingParts" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FSharpCoreMissingParts" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="FSharpCoreMissingParts" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FSharpCoreMissingParts --version 1.1.0
                    
#r "nuget: FSharpCoreMissingParts, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FSharpCoreMissingParts@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FSharpCoreMissingParts&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=FSharpCoreMissingParts&version=1.1.0
                    
Install as a Cake Tool

FSharpCoreMissingParts

FSharpCoreMissingParts is a collection of various useful functions intended to fill missing parts of the F# Core library.

Installation

You can install FSharpCoreMissingParts via NuGet:

Install-Package FSharpCoreMissingParts

Or via .NET CLI:

dotnet add package FSharpCoreMissingParts

Usage

To use FSharpCoreMissingParts in your F# project:

open FSharpCoreMissingParts

If you want to use flexible numeric casting:

open FSharpCoreMissingParts.Casting

Array

tryBinarySearch

Performs a binary search within the specified array. The array must be sorted, otherwise the result can be wrong.

> [|1 .. 100|] |> Array.tryBinarySearch 42;;
val it : int option = Some 41

tryBinarySearchWith

Performs a binary search within the specified array using an external compare function. The array must be sorted, otherwise the result can be wrong.

> let reverseCompare a b = compare b a
[|100 .. -1 .. 1|] |> Array.tryBinarySearchWith reverseCompare 42;;
val it : int option = Some 58

Array2D

ofArray

Create a 2D array from a 1D array by specifying dimensions (rows and columns).

> let nrows, ncolumns = 3, 2;;
val nrows: int = 3
val ncolumns: int = 2

> let arr2d = [|1 .. 6|] |> Array2D.ofArray nrows ncolumns;;
val arr2d : int [,] = [[1; 2]
                       [3; 4]
                       [5; 6]]

toArray

Flattens a 2D array back into a 1D array.

> arr2d |> Array2D.toArray;;
val it : int [] = [|1; 2; 3; 4; 5; 6|]

Casting

^> operator

A type-safe cast operator that performs flexible numeric conversions.

let inline sqrtn n = (n |> float |> sqrt) ^> n

> sqrtn 25;;
val it : int = 5

> sqrtn 25I;;
val it : bigint = 5

> sqrtn 25.;;
val it : double = 5.0

CircularList

Creates an immutable circular list where the last element points back to the first.

> let head = CircularList.ofList [1; 2];;
val head : CircularListNode<int>

> head |> CircularList.value;;
val it : int = 1

> head |> CircularList.next |> CircularList.value;;
val it : int = 2

> head |> CircularList.next |> CircularList.next |> CircularList.value;;
val it : int = 1

value

Returns the actual data stored in the current node.

next

Returns the next node in the list. Since the list is circular, calling next on the last element will seamlessly point back to the first element, allowing for infinite traversal without encountering null or None.

List

pairwiseWrapped

A wrap-around version of List.pairwise that pairs the last element with the first.

> [1] |> List.pairwiseWrapped;;
val it : (int * int) list = [(1, 1)]

> [1 .. 3] |> List.pairwiseWrapped;;
val it : (int * int) list = [(1, 2); (2, 3); (3, 1)]

crossMap

Applies a mapper function to the Cartesian product of two lists. Equivalent to allPairs followed by map.

> List.crossMap (+) [1; 2] [10; 20];;
val it: int list = [11; 21; 12; 22]

Span

stackalloc

Allocates a block of memory on the stack for a specified number of elements. This is useful for temporary buffers that are only needed within the scope of a method, providing high performance without heap allocation.

let span = Span.stackalloc<int> 3
span[0] <- 42

toReadOnlySpan

Converts a Span<'T> to a ReadOnlySpan<'T>, allowing you to work with the data in a read-only context without copying.

let arr = [|1; 2; 3|]
let span = Span arr
span[0] <- 42
let readOnlySpan = Span.toReadOnlySpan span

Mem

A functional style wrapper for ReadOnlyMemory<'T>, allowing zero-allocation slicing and iteration.

ofArray

Wraps an entire array into a ReadOnlyMemory<'T>. This provides a view of the array without copying its elements.

> let mem = Mem.ofArray [|1; 2; 3; 4; 5|];;
val mem : ReadOnlyMemory<int> = 1 2 3 4 5

ofArraySlice

Creates a ReadOnlyMemory<'T> from a specific range of an array. It takes a start index and length, allowing you to work with a sub-section of the array efficiently.

> let memSlice = [|1; 2; 3; 4; 5|] |> Mem.ofArraySlice 1 3;;
val memSlice : ReadOnlyMemory<int> = 2 3 4

ofString

Converts a string into a ReadOnlyMemory<char>. This is useful for performing high-performance string operations without additional allocations.

> let memString = Mem.ofString "가나다";;
val memString : ReadOnlyMemory<char> = '가' '나' '다'

ofStringSlice

Creates a ReadOnlyMemory<char> from a sub-string based on the start index and length. Unlike String.Substring, this operation does not allocate a new string on the heap.

> let memStringSlice = "가나다" |> Mem.ofStringSlice 1 2;;
val memStringSlice : ReadOnlyMemory<char> = '나' '다'

windowed

Yields a sequence of overlapping windows of the specified size.

> "Hello" |> Mem.ofString |> Mem.windowed 3;;
val it: Mem<char> seq =
  seq [Hel {IsEmpty = false;
            Length = 3;
            Span = ?;}; ell {IsEmpty = false;
                             Length = 3;
                             Span = ?;}; llo {IsEmpty = false;
                                              Length = 3;
                                              Span = ?;}]

forall

Returns true if all elements satisfy the given predicate.

> let mem = Mem.ofArray [|1; 2; 3; 4; 5|];;
val mem : ReadOnlyMemory<int> = 1 2 3 4 5

> Mem.forall (fun x -> x > 0) mem;;
val it : bool = true

forall2

Returns true if all elements satisfy the given predicate. The predicate takes two arguments, one from each memory block.

> let mem = Mem.ofArray [|1; 2; 3; 4; 5|];;
val mem : ReadOnlyMemory<int> = 1 2 3 4 5

> let mem2 = Mem.ofArray [|5; 4; 3; 2; 1|];;
val mem2 : ReadOnlyMemory<int> = 5 4 3 2 1

> Mem.forall2 (fun x y -> x + y = 6) mem mem2;;
val it : bool = true

NaturalSort

Provides "human-friendly" sorting that handles numbers within strings logically.

sort

> ["z10"; "z"; "z1"; "z012"; "zz"; "z21"; "z2"] |> NaturalSort.sort;;
val it : string list = ["z"; "z1"; "z2"; "z10"; "z012"; "z21"; "zz"]

Seq

iterate

Generates an infinite sequence by repeatedly applying a function to an initial value. Each element is the result of applying the function to the previous element.

> Seq.iterate (fun x -> x * 2) 1 |> Seq.take 5 |> Seq.toList;;
val it : int list = [1; 2; 4; 8; 16]

foldWhileSome

Similar to Seq.fold, but allows early termination. The folding process continues as long as the folder function returns Some. If it returns None, the sequence processing stops immediately and returns the last state.

> let folder state x =
    if x < 5
    then Some (state + x)
    else None;;
val folder : state:int -> x:int -> int option

> [1 .. 10] |> Seq.foldWhileSome folder 0;;
val it : int = 10

isOrdered

Checks if a sequence is sorted according to the specified SortOrder, which is one of Ascending, Descending, StrictAscending, or StrictDescending.

> [1; 2; 2; 3] |> Seq.isOrdered Ascending;;
val it : bool = true

> [1; 2; 2; 3] |> Seq.isOrdered StrictAscending;;
val it : bool = false

> [3; 3; 2; 1] |> Seq.isOrdered Descending;;
val it : bool = true

> [3; 3; 2; 1] |> Seq.isOrdered StrictDescending;;
val it : bool = false

String

ofSeq

Creates a string from the specified char sequence.

> ['a' .. 'f'] |> String.ofSeq;;
val it : string = "abcdef"

ellipsize

Shortens a string to the specified length. The last character is replaced with an ellipsis (U+2026).

> "abcde" |> String.ellipsize 3;;
val it : string = "ab…"

suffixes

Generates all suffixes of the string, from longest to shortest.

> "bjy" |> String.suffixes;;
val it : string seq = seq ["bjy"; "jy"; "y"]
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 115 3/10/2026
1.0.1 129 2/20/2026
1.0.0 110 2/19/2026