tweak: In Danger namespace, further diminishingMarginalReturnsSkeleton

This commit is contained in:
NunoSempere 2022-09-05 14:12:34 +02:00
parent aa3173f85b
commit fe3075b3bf
2 changed files with 13 additions and 9 deletions

View File

@ -69,8 +69,8 @@ module Internals = {
result result
} }
let castFloatToInternalNumber = x => ReducerInterface_InternalExpressionValue.IEvNumber(x) let castFloatToInternalNumber = x => ReducerInterface_InternalExpressionValue.IEvNumber(x)
@dead let castArrayOfFloatsToInternalArrayOfInternals = xs => ReducerInterface_InternalExpressionValue.IEvArray(Belt.Array.map(xs, x => castFloatToInternalNumber(x)))
let applyFunctionAtFloat = (aLambda, point, environment, reducer) => @dead let applyFunctionAtFloat = (aLambda, point, environment, reducer) =>
// reason for existence: might be an useful template to have for calculating diminishing marginal returns later on // reason for existence: might be an useful template to have for calculating diminishing marginal returns later on
applyFunctionAtPoint(aLambda, castFloatToInternalNumber(point), environment, reducer) applyFunctionAtPoint(aLambda, castFloatToInternalNumber(point), environment, reducer)
// integrate function itself // integrate function itself
@ -176,7 +176,7 @@ module Internals = {
environment, environment,
reducer, reducer,
) => { ) => {
Ok(castFloatToInternalNumber(0.0)) Ok(castArrayOfFloatsToInternalArrayOfInternals([0.0, 1.0]))
} }
} }
@ -355,7 +355,7 @@ let library = [
Function.make( Function.make(
~name="diminishingMarginalReturnsSkeleton", ~name="diminishingMarginalReturnsSkeleton",
~nameSpace, ~nameSpace,
~output=EvtNumber, ~output=EvtArray,
~requiresNamespace=false, ~requiresNamespace=false,
~examples=[`Danger.diminishingMarginalReturnsSkeleton({|x| x+1}, {|y| 10}, 100, 1)`], ~examples=[`Danger.diminishingMarginalReturnsSkeleton({|x| x+1}, {|y| 10}, 100, 1)`],
~definitions=[ ~definitions=[

View File

@ -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", ~name="map",
~inputs=[FRTypeArray(FRTypeAny), FRTypeLambda], ~inputs=[FRTypeArray(FRTypeAny), FRTypeLambda],
~run=(inputs, _, env, reducer) => ~run=(inputs, _, env, reducer) =>
switch inputs { {
let result = switch inputs {
| [IEvArray(array), IEvLambda(lambda)] => | [IEvArray(array), IEvLambda(lambda)] =>
Internals.map(array, env, lambda, reducer)->E.R2.errMap(_ => "Error!") Internals.map(array, env, lambda, reducer)->E.R2.errMap(_ => "Error!")
| _ => Error(impossibleError) | _ => Error(impossibleError)
}
result
}, },
(), (),
), ),