CallableFunction -> FunctionCall

This commit is contained in:
Ozzie Gooen 2020-07-31 12:31:39 +01:00
parent 7aac191059
commit bcbbcf0f43
4 changed files with 10 additions and 12 deletions

View File

@ -336,7 +336,7 @@ let toLeaf =
| `Render(t) => Render.operationToLeaf(evaluationParams, t)
| `Function(t) => Ok(`Function(t))
| `Symbol(r) => ExpressionTypes.ExpressionTree.Environment.get(evaluationParams.environment, r) |> E.O.toResult("Undeclared variable " ++ r)
| `CallableFunction(name, args) =>
| `FunctionCall(name, args) =>
callableFunction(evaluationParams, name, args)
};
};

View File

@ -21,7 +21,7 @@ module ExpressionTree = {
| `Normalize(node)
| `FloatFromDist(distToFloatOperation, node)
| `Function(array(string), node)
| `CallableFunction(string, array(node))
| `FunctionCall(string, array(node))
| `Symbol(string)
];

View File

@ -69,7 +69,6 @@ let processCustomFn =
),
evaluateNode: evaluationParams.evaluateNode,
};
Js.log4("HI", newEnvironment, newEvaluationParams, args);
evaluationParams.evaluateNode(newEvaluationParams, fnResult);
} else {
Error("Failure");
@ -80,8 +79,7 @@ let fnn =
evaluationParams: ExpressionTypes.ExpressionTree.evaluationParams,
name,
args: array(node),
) => {
Js.log3("Trying function", name, evaluationParams.environment);
) =>
switch (
name,
ExpressionTypes.ExpressionTree.Environment.get(
@ -89,7 +87,8 @@ let fnn =
name,
),
) {
| (_, Some(`Function(argNames, tt))) => processCustomFn(evaluationParams, args, argNames, tt)
| (_, Some(`Function(argNames, tt))) =>
processCustomFn(evaluationParams, args, argNames, tt)
| ("normal", _) =>
apply2(twoFloatsToOkSym(SymbolicDist.Normal.make), args)
| ("uniform", _) =>
@ -121,4 +120,3 @@ let fnn =
| ("to", _) => to_(args)
| _ => Error("Function not found")
};
};

View File

@ -127,10 +127,10 @@ module MathAdtToDistDst = {
switch (g("mean"), g("stdev"), g("mu"), g("sigma")) {
| (Ok(mean), Ok(stdev), _, _) =>
Ok(
`CallableFunction(("lognormalFromMeanAndStdDev", [|mean, stdev|])),
`FunctionCall(("lognormalFromMeanAndStdDev", [|mean, stdev|])),
)
| (_, _, Ok(mu), Ok(sigma)) =>
Ok(`CallableFunction(("lognormal", [|mu, sigma|])))
Ok(`FunctionCall(("lognormal", [|mu, sigma|])))
| _ =>
Error(
"Lognormal distribution needs either mean and stdev or mu and sigma",
@ -139,7 +139,7 @@ module MathAdtToDistDst = {
| _ =>
parseArgs()
|> E.R.fmap((args: array(ExpressionTypes.ExpressionTree.node)) =>
`CallableFunction(("lognormal", args))
`FunctionCall(("lognormal", args))
)
};
@ -252,7 +252,7 @@ module MathAdtToDistDst = {
| "cauchy" =>
parseArgs()
|> E.R.fmap((args: array(ExpressionTypes.ExpressionTree.node)) =>
`CallableFunction((name, args))
`FunctionCall((name, args))
)
| "lognormal" => lognormal(args, parseArgs, nodeParser)
| "mm" =>
@ -298,7 +298,7 @@ module MathAdtToDistDst = {
| name =>
parseArgs()
|> E.R.fmap((args: array(ExpressionTypes.ExpressionTree.node)) =>
`CallableFunction((name, args))
`FunctionCall((name, args))
)
};
};