From 943e63b3790cf1bdacc1f598ab7ac8211c662aa4 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sun, 4 Sep 2022 20:26:57 +0200 Subject: [PATCH] link: run pretty --- .vscode/settings.json | 3 +++ ...leLibrary_FunctionRegistryLibrary_test.res | 10 ++++++-- .../FunctionRegistry/Library/FR_Danger.res | 25 +++++++++---------- 3 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..f67fd72e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "rescript.settings.autoRunCodeAnalysis": true +} diff --git a/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res b/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res index 7ddb57d4..82933838 100644 --- a/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res +++ b/packages/squiggle-lang/__tests__/SquiggleLibrary/SquiggleLibrary_FunctionRegistryLibrary_test.res @@ -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])", diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Danger.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Danger.res index 4aad2aae..56bb33e3 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Danger.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Danger.res @@ -61,23 +61,22 @@ 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 applyFunctionAtPoint = ( + aLambda, + internalNumber: internalExpressionValue, + environment, + reducer, + ): result => { let x = internalNumber - let result = Reducer_Expression_Lambda.doLambdaCall( - aLambda, - list{x}, - environment, - reducer, - ) + 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 integrateFunction = (aLambda, min:float, max:float, increment, environment, reducer) => { + 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 }