link: run pretty

This commit is contained in:
NunoSempere 2022-09-04 20:26:57 +02:00
parent b292a3e6fd
commit 943e63b379
3 changed files with 23 additions and 15 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"rescript.settings.autoRunCodeAnalysis": true
}

View File

@ -63,9 +63,15 @@ describe("FunctionRegistry Library", () => {
testEvalToBe("SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5])", "Ok(Sample Set Distribution)")
testEvalToBe("SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5])", "Ok(Sample Set Distribution)")
testEvalToBe("SampleSet.fromFn({|| sample(normal(5,2))})", "Ok(Sample Set Distribution)")
testEvalToBe("SampleSet.min(SampleSet.fromDist(normal(50,2)), 2)", "Ok(Sample Set Distribution)")
testEvalToBe(
"SampleSet.min(SampleSet.fromDist(normal(50,2)), 2)",
"Ok(Sample Set Distribution)",
)
testEvalToBe("mean(SampleSet.min(SampleSet.fromDist(normal(50,2)), 2))", "Ok(2)")
testEvalToBe("SampleSet.max(SampleSet.fromDist(normal(50,2)), 10)", "Ok(Sample Set Distribution)")
testEvalToBe(
"SampleSet.max(SampleSet.fromDist(normal(50,2)), 10)",
"Ok(Sample Set Distribution)",
)
testEvalToBe(
"addOne(t)=t+1; SampleSet.toList(SampleSet.map(SampleSet.fromList([1,2,3,4,5,6]), addOne))",
"Ok([2,3,4,5,6,7])",

View File

@ -61,22 +61,21 @@ module Internals = {
let choose = ((n, k)) => factorial(n) /. (factorial(n -. k) *. factorial(k))
let pow = (base, exp) => Js.Math.pow_float(~base, ~exp)
let binomial = ((n, k, p)) => choose((n, k)) *. pow(p, k) *. pow(1.0 -. p, n -. k)
let applyFunctionAtPoint = (aLambda, internalNumber: internalExpressionValue, environment, reducer): result<
ReducerInterface_InternalExpressionValue.t,
Reducer_ErrorValue.errorValue,
> => {
let x = internalNumber
let result = Reducer_Expression_Lambda.doLambdaCall(
let applyFunctionAtPoint = (
aLambda,
list{x},
internalNumber: internalExpressionValue,
environment,
reducer,
)
): result<ReducerInterface_InternalExpressionValue.t, Reducer_ErrorValue.errorValue> => {
let x = internalNumber
let result = Reducer_Expression_Lambda.doLambdaCall(aLambda, list{x}, environment, reducer)
result
}
let internalZero = ReducerInterface_InternalExpressionValue.IEvNumber(0.0)
let applyFunctionAtZero = (aLambda,environment , reducer) => applyFunctionAtPoint(aLambda, internalZero, environment, reducer)
let applyFunctionAtFloat = (aLambda, point, environment, reducer) => applyFunctionAtPoint(aLambda, ReducerInterface_InternalExpressionValue.IEvNumber(point))
let applyFunctionAtZero = (aLambda, environment, reducer) =>
applyFunctionAtPoint(aLambda, internalZero, environment, reducer)
let applyFunctionAtFloat = (aLambda, point, environment, reducer) =>
applyFunctionAtPoint(aLambda, ReducerInterface_InternalExpressionValue.IEvNumber(point))
let integrateFunction = (aLambda, min: float, max: float, increment, environment, reducer) => {
// Should be easy, but tired today.
0.0