CallableFunction -> FunctionCall
This commit is contained in:
parent
7aac191059
commit
bcbbcf0f43
|
@ -336,7 +336,7 @@ let toLeaf =
|
||||||
| `Render(t) => Render.operationToLeaf(evaluationParams, t)
|
| `Render(t) => Render.operationToLeaf(evaluationParams, t)
|
||||||
| `Function(t) => Ok(`Function(t))
|
| `Function(t) => Ok(`Function(t))
|
||||||
| `Symbol(r) => ExpressionTypes.ExpressionTree.Environment.get(evaluationParams.environment, r) |> E.O.toResult("Undeclared variable " ++ r)
|
| `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)
|
callableFunction(evaluationParams, name, args)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,7 +21,7 @@ module ExpressionTree = {
|
||||||
| `Normalize(node)
|
| `Normalize(node)
|
||||||
| `FloatFromDist(distToFloatOperation, node)
|
| `FloatFromDist(distToFloatOperation, node)
|
||||||
| `Function(array(string), node)
|
| `Function(array(string), node)
|
||||||
| `CallableFunction(string, array(node))
|
| `FunctionCall(string, array(node))
|
||||||
| `Symbol(string)
|
| `Symbol(string)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,6 @@ let processCustomFn =
|
||||||
),
|
),
|
||||||
evaluateNode: evaluationParams.evaluateNode,
|
evaluateNode: evaluationParams.evaluateNode,
|
||||||
};
|
};
|
||||||
Js.log4("HI", newEnvironment, newEvaluationParams, args);
|
|
||||||
evaluationParams.evaluateNode(newEvaluationParams, fnResult);
|
evaluationParams.evaluateNode(newEvaluationParams, fnResult);
|
||||||
} else {
|
} else {
|
||||||
Error("Failure");
|
Error("Failure");
|
||||||
|
@ -80,8 +79,7 @@ let fnn =
|
||||||
evaluationParams: ExpressionTypes.ExpressionTree.evaluationParams,
|
evaluationParams: ExpressionTypes.ExpressionTree.evaluationParams,
|
||||||
name,
|
name,
|
||||||
args: array(node),
|
args: array(node),
|
||||||
) => {
|
) =>
|
||||||
Js.log3("Trying function", name, evaluationParams.environment);
|
|
||||||
switch (
|
switch (
|
||||||
name,
|
name,
|
||||||
ExpressionTypes.ExpressionTree.Environment.get(
|
ExpressionTypes.ExpressionTree.Environment.get(
|
||||||
|
@ -89,7 +87,8 @@ let fnn =
|
||||||
name,
|
name,
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
| (_, Some(`Function(argNames, tt))) => processCustomFn(evaluationParams, args, argNames, tt)
|
| (_, Some(`Function(argNames, tt))) =>
|
||||||
|
processCustomFn(evaluationParams, args, argNames, tt)
|
||||||
| ("normal", _) =>
|
| ("normal", _) =>
|
||||||
apply2(twoFloatsToOkSym(SymbolicDist.Normal.make), args)
|
apply2(twoFloatsToOkSym(SymbolicDist.Normal.make), args)
|
||||||
| ("uniform", _) =>
|
| ("uniform", _) =>
|
||||||
|
@ -121,4 +120,3 @@ let fnn =
|
||||||
| ("to", _) => to_(args)
|
| ("to", _) => to_(args)
|
||||||
| _ => Error("Function not found")
|
| _ => Error("Function not found")
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
|
@ -127,10 +127,10 @@ module MathAdtToDistDst = {
|
||||||
switch (g("mean"), g("stdev"), g("mu"), g("sigma")) {
|
switch (g("mean"), g("stdev"), g("mu"), g("sigma")) {
|
||||||
| (Ok(mean), Ok(stdev), _, _) =>
|
| (Ok(mean), Ok(stdev), _, _) =>
|
||||||
Ok(
|
Ok(
|
||||||
`CallableFunction(("lognormalFromMeanAndStdDev", [|mean, stdev|])),
|
`FunctionCall(("lognormalFromMeanAndStdDev", [|mean, stdev|])),
|
||||||
)
|
)
|
||||||
| (_, _, Ok(mu), Ok(sigma)) =>
|
| (_, _, Ok(mu), Ok(sigma)) =>
|
||||||
Ok(`CallableFunction(("lognormal", [|mu, sigma|])))
|
Ok(`FunctionCall(("lognormal", [|mu, sigma|])))
|
||||||
| _ =>
|
| _ =>
|
||||||
Error(
|
Error(
|
||||||
"Lognormal distribution needs either mean and stdev or mu and sigma",
|
"Lognormal distribution needs either mean and stdev or mu and sigma",
|
||||||
|
@ -139,7 +139,7 @@ module MathAdtToDistDst = {
|
||||||
| _ =>
|
| _ =>
|
||||||
parseArgs()
|
parseArgs()
|
||||||
|> E.R.fmap((args: array(ExpressionTypes.ExpressionTree.node)) =>
|
|> E.R.fmap((args: array(ExpressionTypes.ExpressionTree.node)) =>
|
||||||
`CallableFunction(("lognormal", args))
|
`FunctionCall(("lognormal", args))
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ module MathAdtToDistDst = {
|
||||||
| "cauchy" =>
|
| "cauchy" =>
|
||||||
parseArgs()
|
parseArgs()
|
||||||
|> E.R.fmap((args: array(ExpressionTypes.ExpressionTree.node)) =>
|
|> E.R.fmap((args: array(ExpressionTypes.ExpressionTree.node)) =>
|
||||||
`CallableFunction((name, args))
|
`FunctionCall((name, args))
|
||||||
)
|
)
|
||||||
| "lognormal" => lognormal(args, parseArgs, nodeParser)
|
| "lognormal" => lognormal(args, parseArgs, nodeParser)
|
||||||
| "mm" =>
|
| "mm" =>
|
||||||
|
@ -298,7 +298,7 @@ module MathAdtToDistDst = {
|
||||||
| name =>
|
| name =>
|
||||||
parseArgs()
|
parseArgs()
|
||||||
|> E.R.fmap((args: array(ExpressionTypes.ExpressionTree.node)) =>
|
|> E.R.fmap((args: array(ExpressionTypes.ExpressionTree.node)) =>
|
||||||
`CallableFunction((name, args))
|
`FunctionCall((name, args))
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user