diff --git a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res index d5fa99b6..e4e443fe 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/PointSetDist/PointSetDist.res @@ -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), ()) } diff --git a/packages/squiggle-lang/src/rescript/Utility/E.res b/packages/squiggle-lang/src/rescript/Utility/E.res index b3119da3..30b48881 100644 --- a/packages/squiggle-lang/src/rescript/Utility/E.res +++ b/packages/squiggle-lang/src/rescript/Utility/E.res @@ -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): array => 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 => + let rec rangeFloat = (~step: float=1.0, start : float, end: float) : array => 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) => {