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
Deprecated
Use forEach instead
RESCRIPT
let forEachU: (int, int, int => unit) => unitforEach
RESCRIPT
let forEach: (int, int, int => unit) => unitforEach(start, finish, action) equivalent to Belt.Array.forEach(Belt.Array.range(start, finish), action))
Examples
RESCRIPTBelt.Range.forEach(0, 4, i => Js.log(i))
// Prints:
// 0
// 1
// 2
// 3
// 4
everyU
Deprecated
Use every instead
RESCRIPT
let everyU: (int, int, int => bool) => boolevery
RESCRIPT
let every: (int, int, int => bool) => boolevery(start, finish, p) equivalent to Belt.Array.every(Belt.Array.range(start, finish), p)
Examples
RESCRIPTBelt.Range.every(0, 4, i => i < 5) == true
Belt.Range.every(0, 4, i => i < 4) == false
everyByU
Deprecated
Use everyBy instead
RESCRIPT
let everyByU: (int, int, ~step: int, int => bool) => booleveryBy
RESCRIPT
let everyBy: (int, int, ~step: int, int => bool) => booleveryBy(start, finish, ~step, p). See Belt.Array.rangeBy, equivalent to
Belt.Array.every(Belt.Array.rangeBy(start, finish, ~step), p)
Examples
RESCRIPTBelt.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
Deprecated
Use some instead
RESCRIPT
let someU: (int, int, int => bool) => boolsome
RESCRIPT
let some: (int, int, int => bool) => boolsome(start, finish, p) equivalent to Belt.Array.some(Belt.Array.range(start, finish), p)
Examples
RESCRIPTBelt.Range.some(0, 4, i => i > 5) == false
Belt.Range.some(0, 4, i => i > 2) == true
someByU
Deprecated
Use someBy instead
RESCRIPT
let someByU: (int, int, ~step: int, int => bool) => boolsomeBy
RESCRIPT
let someBy: (int, int, ~step: int, int => bool) => bool