This is the latest docs version
Quick Links
  • -Overview
  • -Language Features
  • -JS Interop
  • -Build System
Documentation
Language Manual
Reference for all language features
ReScript & React
First class bindings for ReactJS
GenType
Seamless TypeScript integration
Reanalyze
Dead Code & Termination analysis
Exploration
Packages
Explore third party libraries and bindings
Syntax Lookup
Discover all syntax constructs
APIPlaygroundBlogCommunity
  • Playground
  • Blog
  • Twitter
  • GitHub
  • Forum
Belt Module
Overview
Belt
submodules
  • Array
  • Float
  • HashMap
    • String
    • Int
    HashSet
    • String
    • Int
    Id
    • MakeHashable
    • MakeHashableU
    • MakeComparable
    • MakeComparableU
  • Int
  • List
  • Map
    • Dict
    • String
    • Int
    MutableMap
    • String
    • Int
  • MutableQueue
  • MutableSet
    • String
    • Int
  • MutableStack
  • Option
  • Range
  • Result
  • Set
    • Dict
    • String
    • Int
    SortArray
    • String
      • t
        element
      • v
        strictlySortedLength
      • v
        isSorted
      • v
        stableSortInPlace
      • v
        stableSort
      • v
        binarySearch
      • v
        union
      • v
        intersect
      • v
        diff
    • Int
    API / Belt / Sortarray / String

    String

    This is a specialized module for Belt_SortArray, the docs in that module also applies here, except the comparator is fixed and inlined

    element

    RESCRIPT
    type element = string

    strictlySortedLength

    RESCRIPT
    let strictlySortedLength: array<element> => int

    The same as Belt_SortArray.strictlySortedLength except the comparator is fixed

    return +n means increasing order -n means negative order

    isSorted

    RESCRIPT
    let isSorted: array<element> => bool

    sorted(xs) return true if xs is in non strict increasing order

    stableSortInPlace

    RESCRIPT
    let stableSortInPlace: array<element> => unit

    The same as Belt_SortArray.stableSortInPlaceBy except the comparator is fixed

    stableSort

    RESCRIPT
    let stableSort: array<element> => array<element>

    The same as Belt_SortArray.stableSortBy except the comparator is fixed

    binarySearch

    RESCRIPT
    let binarySearch: (array<element>, element) => int

    If value is not found and value is less than one or more elements in array, the negative number returned is the bitwise complement of the index of the first element that is larger than value.

    If value is not found and value is greater than all elements in array, the negative number returned is the bitwise complement of (the index of the last element plus 1)

    for example, if key is smaller than all elements return -1 since lnot (-1) = 0 if key is larger than all elements return - (len + 1) since lnot (-(len+1)) = len

    union

    RESCRIPT
    let union: ( array<element>, int, int, array<element>, int, int, array<element>, int, ) => int

    union(src, src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs, cmp) assume src and src2 is strictly sorted. for equivalent elements, it is picked from src also assume that dst is large enough to store all elements

    intersect

    RESCRIPT
    let intersect: ( array<element>, int, int, array<element>, int, int, array<element>, int, ) => int

    diff

    RESCRIPT
    let diff: ( array<element>, int, int, array<element>, int, int, array<element>, int, ) => int
    Types and values
    • t
      element
    • v
      strictlySortedLength
    • v
      isSorted
    • v
      stableSortInPlace
    • v
      stableSort
    • v
      binarySearch
    • v
      union
    • v
      intersect
    • v
      diff

    © 2024 The ReScript Project

    Software and assets distribution powered by KeyCDN.

    About
    • Community
    • ReScript Association
    Find us on