From fe3075b3bf8a39aae79414a5a5de79cd355be214 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Mon, 5 Sep 2022 14:12:34 +0200 Subject: [PATCH] tweak: In Danger namespace, further diminishingMarginalReturnsSkeleton --- .../FunctionRegistry/Library/FR_Danger.res | 8 ++++---- .../rescript/FunctionRegistry/Library/FR_List.res | 14 +++++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) 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 6136e46a..e9684b2a 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Danger.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Danger.res @@ -69,8 +69,8 @@ module Internals = { result } let castFloatToInternalNumber = x => ReducerInterface_InternalExpressionValue.IEvNumber(x) - @dead - let applyFunctionAtFloat = (aLambda, point, environment, reducer) => + let castArrayOfFloatsToInternalArrayOfInternals = xs => ReducerInterface_InternalExpressionValue.IEvArray(Belt.Array.map(xs, x => castFloatToInternalNumber(x))) + @dead let applyFunctionAtFloat = (aLambda, point, environment, reducer) => // reason for existence: might be an useful template to have for calculating diminishing marginal returns later on applyFunctionAtPoint(aLambda, castFloatToInternalNumber(point), environment, reducer) // integrate function itself @@ -176,7 +176,7 @@ module Internals = { environment, reducer, ) => { - Ok(castFloatToInternalNumber(0.0)) + Ok(castArrayOfFloatsToInternalArrayOfInternals([0.0, 1.0])) } } @@ -355,7 +355,7 @@ let library = [ Function.make( ~name="diminishingMarginalReturnsSkeleton", ~nameSpace, - ~output=EvtNumber, + ~output=EvtArray, ~requiresNamespace=false, ~examples=[`Danger.diminishingMarginalReturnsSkeleton({|x| x+1}, {|y| 10}, 100, 1)`], ~definitions=[ diff --git a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_List.res b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_List.res index 762fe31b..91a93544 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_List.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_List.res @@ -75,7 +75,8 @@ module Internals = { }) }) ) - rMappedList->E.R2.fmap(mappedList => mappedList->Belt.List.toArray->Wrappers.evArray) + let result = rMappedList->E.R2.fmap(mappedList => mappedList->Belt.List.toArray->Wrappers.evArray) + result } } @@ -190,10 +191,13 @@ let library = [ ~name="map", ~inputs=[FRTypeArray(FRTypeAny), FRTypeLambda], ~run=(inputs, _, env, reducer) => - switch inputs { - | [IEvArray(array), IEvLambda(lambda)] => - Internals.map(array, env, lambda, reducer)->E.R2.errMap(_ => "Error!") - | _ => Error(impossibleError) + { + let result = switch inputs { + | [IEvArray(array), IEvLambda(lambda)] => + Internals.map(array, env, lambda, reducer)->E.R2.errMap(_ => "Error!") + | _ => Error(impossibleError) + } + result }, (), ),