Rename rangeByFloat to rangeFloat

This commit is contained in:
Sam Nolan 2022-04-08 11:09:31 +10:00
parent bf2f85a8ab
commit a99290ea43
2 changed files with 3 additions and 5 deletions

View File

@ -173,7 +173,7 @@ let cdf = T.Integral.xToY
let toSparkline = (buckets: int, t: t ): string => {
let size : float = T.maxX(t) -. T.minX(t)
let stepSize = size /. Belt.Int.toFloat(buckets)
let cdfImage = E.A.rangeByFloat(~step=stepSize, T.minX(t), T.maxX(t)) -> Belt.Array.map(val => cdf(val,t))
let cdfImage = E.A.rangeFloat(~step=stepSize, T.minX(t), T.maxX(t)) -> Belt.Array.map(val => cdf(val,t))
Sparklines.create(E.A.diff(cdfImage), ())
}

View File

@ -289,16 +289,14 @@ module A = {
))
|> Rationale.Result.return
}
let rangeFloat = (~step=1, start, stop) =>
Belt.Array.rangeBy(start, stop, ~step) |> fmap(Belt.Int.toFloat)
let diff = (arr: array<float>): array<float> =>
Belt.Array.zipBy(arr, Belt.Array.sliceToEnd(arr, 1), (left, right) => right -. left)
let rec rangeByFloat = (~step: float=1.0, start : float, end: float) : array<float> =>
let rec rangeFloat = (~step: float=1.0, start : float, end: float) : array<float> =>
start > end ?
[]
: Belt.Array.concat([start], rangeByFloat(~step, start +. step, end))
: Belt.Array.concat([start], rangeFloat(~step, start +. step, end))
// This zips while taking the longest elements of each array.
let zipMaxLength = (array1, array2) => {