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 cc93abdb..974e8be0 100644 --- a/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Danger.res +++ b/packages/squiggle-lang/src/rescript/FunctionRegistry/Library/FR_Danger.res @@ -74,6 +74,8 @@ module Internals = { ) result } + let internalZero = ReducerInterface_InternalExpressionValue.IEvNumber(0.0) + let applyFunctionAtZero = (aLambda) => applyFunctionAtPoint(aLambda, internalZero) } @@ -127,6 +129,27 @@ let library = [ ~definitions=[FunctionToNumberZero.make("functionToZero", x => x)], (), ), + Function.make( + ~name="applyFunctionAtZero", + ~nameSpace, + ~output=EvtArray, + ~requiresNamespace=false, + ~examples=[`Danger.applyFunctionAtZero({|x| x+1})`], + ~definitions=[ + FnDefinition.make( + ~name="applyFunctionAtPoint", + ~inputs=[FRTypeLambda], + ~run=(inputs, _, env, reducer) => + switch inputs { + | [IEvLambda(aLambda)] => + Internals.applyFunctionAtZero(aLambda, env, reducer)->E.R2.errMap(_ => "Error!") + | _ => Error(impossibleError) + }, + (), + ), + ], + (), + ), Function.make( ~name="applyFunctionAtPoint", ~nameSpace,