Skip to main content

Module TableclothSet.Poly

Construct sets which can hold any data type using the polymorphic compare function.

type identity​

type identity

type t​

type nonrec 'a t = ( 'a, identity ) t

val empty​

val empty : unit -> 'a t

The empty set.

A great starting point.

val singleton​

val singleton : 'a -> 'a t

Create a set of a single value

Examples

Set.Int.singleton (5, "Emu") |> Set.toList = [(5, "Emu")]

val fromArray​

val fromArray : 'a array -> 'a t

Create a set from an Array

Examples

Set.Poly.fromArray [(1, "Ant");(2, "Bat");(2, "Bat")] |> Set.toList = [(1, "Ant"); (2, "Bat")]

val from_array​

val from_array : 'a array -> 'a t

val fromList​

val fromList : 'a list -> 'a t

Create a set from a List

Examples

Set.Poly.fromList [(1, "Ant");(2, "Bat");(2, "Bat")] |> Set.toList = [(1, "Ant"); (2, "Bat")]

val from_list​

val from_list : 'a list -> 'a t