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
    • v
      forEachU
    • v
      forEach
    • v
      everyU
    • v
      every
    • v
      everyByU
    • v
      everyBy
    • v
      someU
    • v
      some
    • v
      someByU
    • v
      someBy
  • Result
  • Set
    • Dict
    • String
    • Int
    SortArray
    • String
    • Int
    API / Belt / Range

    Range

    A small utility module to provide inclusive range operations for [start, finish]. Internally it is relying on loops instead of creating new arrays, which makes it pretty performant and memory friendly.

    forEachU

    RESCRIPT
    let forEachU: (int, int, int => unit) => unit

    forEach

    RESCRIPT
    let forEach: (int, int, int => unit) => unit

    forEach(start, finish, action) equivalent to Belt.Array.forEach(Belt.Array.range(start, finish), action))

    Examples

    RESCRIPT
    Belt.Range.forEach(0, 4, (i) => Js.log(i)) // Prints: // 0 // 1 // 2 // 3 // 4

    everyU

    RESCRIPT
    let everyU: (int, int, int => bool) => bool

    every

    RESCRIPT
    let every: (int, int, int => bool) => bool

    every(start, finish, p) equivalent to Belt.Array.every(Belt.Array.range(start, finish), p)

    Examples

    RESCRIPT
    Belt.Range.every(0, 4, (i) => i < 5) /* true */ Belt.Range.every(0, 4, (i) => i < 4) /* false */

    everyByU

    RESCRIPT
    let everyByU: (int, int, ~step: int, int => bool) => bool

    everyBy

    RESCRIPT
    let everyBy: (int, int, ~step: int, int => bool) => bool

    everyBy(start, finish, ~step, p). See Belt.Array.rangeBy, equivalent to Belt.Array.every(Belt.Array.rangeBy(start, finish, ~step), p)

    Examples

    RESCRIPT
    Belt.Range.everyBy(0, 4, ~step=1, (i) => mod(i, 2) === 0) /* false */ Belt.Range.everyBy(0, 4, ~step=2, (i) => mod(i, 2) === 0) /* true */

    someU

    RESCRIPT
    let someU: (int, int, int => bool) => bool

    some

    RESCRIPT
    let some: (int, int, int => bool) => bool

    some(start, finish, p) equivalent to Belt.Array.some(Belt.Array.range(start, finish), p)

    Examples

    RESCRIPT
    Belt.Range.some(0, 4, (i) => i > 5) /* false */ Belt.Range.some(0, 4, (i) => i > 2) /* true */

    someByU

    RESCRIPT
    let someByU: (int, int, ~step: int, int => bool) => bool

    someBy

    RESCRIPT
    let someBy: (int, int, ~step: int, int => bool) => bool

    someBy(start, finish, ~step, p) See Belt.Array.rangeBy, equivalent to Belt.Array.some(Belt.Array.rangeBy(start, finish, ~step), p)

    Examples

    RESCRIPT
    Belt.Range.someBy(1, 5, ~step=2, (i) => mod(i, 2) === 0) /* false */ Belt.Range.someBy(0, 4, ~step=2, (i) => mod(i, 2) === 0) /* true */
    Types and values
    • v
      forEachU
    • v
      forEach
    • v
      everyU
    • v
      every
    • v
      everyByU
    • v
      everyBy
    • v
      someU
    • v
      some
    • v
      someByU
    • v
      someBy

    © 2024 The ReScript Project

    Software and assets distribution powered by KeyCDN.

    About
    • Community
    • ReScript Association
    Find us on