46 lines
1.0 KiB
Plaintext
46 lines
1.0 KiB
Plaintext
|
open FunctionRegistry_Core
|
||
|
open FunctionRegistry_Helpers
|
||
|
|
||
|
let nameSpace = "Danger"
|
||
|
let requiresNamespace = true
|
||
|
|
||
|
module TwoNumbersToNumber = {
|
||
|
let make = (name, fn) =>
|
||
|
FnDefinition.make(
|
||
|
~name,
|
||
|
~inputs=[FRTypeNumber, FRTypeNumber],
|
||
|
~run=(_, inputs, _, _) => {
|
||
|
inputs->Prepare.ToValueTuple.twoNumbers->E.R2.fmap(fn)->E.R2.fmap(Wrappers.evNumber)
|
||
|
},
|
||
|
(),
|
||
|
)
|
||
|
}
|
||
|
|
||
|
module ThreeNumbersToNumber = {
|
||
|
let make = (name, fn) =>
|
||
|
FnDefinition.make(
|
||
|
~name,
|
||
|
~inputs=[FRTypeNumber, FRTypeNumber, FRTypeNumber],
|
||
|
~run=(_, inputs, _, _) => {
|
||
|
inputs->Prepare.ToValueTuple.threeNumbers->E.R2.fmap(fn)->E.R2.fmap(Wrappers.evNumber)
|
||
|
},
|
||
|
(),
|
||
|
)
|
||
|
}
|
||
|
|
||
|
let library = [
|
||
|
Function.make(
|
||
|
~name="laplace",
|
||
|
~nameSpace,
|
||
|
~requiresNamespace,
|
||
|
~output=EvtNumber,
|
||
|
~examples=[`laplace(1, 20)`],
|
||
|
~definitions=[
|
||
|
TwoNumbersToNumber.make("laplace", ((successes, trials)) =>
|
||
|
(successes +. 1.0) /. (trials +. 1.0)
|
||
|
),
|
||
|
],
|
||
|
(),
|
||
|
),
|
||
|
]
|