Minor cleanup
This commit is contained in:
parent
173c17e13d
commit
6f25fca814
|
@ -274,8 +274,7 @@ module Matcher = {
|
|||
|
||||
module Registry = {
|
||||
let _findExactMatches = (r: registry, fnName: string, args: array<internalExpressionValue>) => {
|
||||
let functionMatchPairs =
|
||||
r.functions->E.A2.fmap(l => (l, Function.match(l, fnName, args)))
|
||||
let functionMatchPairs = r.functions->E.A2.fmap(l => (l, Function.match(l, fnName, args)))
|
||||
let fullMatch = functionMatchPairs->E.A.getBy(((_, match)) => Match.isFullMatch(match))
|
||||
fullMatch->E.O.bind(((fn, match)) =>
|
||||
switch match {
|
||||
|
@ -416,9 +415,10 @@ module Registry = {
|
|||
r.functions->E.A2.fmap(fn => fn.examples->E.A2.fmap(example => (fn, example)))->E.A.concatMany
|
||||
|
||||
let buildFnNameDict = (r: array<function>): fnNameDict => {
|
||||
let allDefinitionsWithFns = r
|
||||
->E.A2.fmap(fn => fn.definitions->E.A2.fmap(definitions => (fn, definitions)))
|
||||
->E.A.concatMany
|
||||
let allDefinitionsWithFns =
|
||||
r
|
||||
->E.A2.fmap(fn => fn.definitions->E.A2.fmap(definitions => (fn, definitions)))
|
||||
->E.A.concatMany
|
||||
let functionsWithFnNames =
|
||||
allDefinitionsWithFns
|
||||
->E.A2.fmap(((fn, def)) => {
|
||||
|
@ -440,7 +440,7 @@ module Registry = {
|
|||
cacheAsArray->Js.Dict.fromArray
|
||||
}
|
||||
|
||||
let make = (fns: array<function>):registry => {
|
||||
let make = (fns: array<function>): registry => {
|
||||
let dict = buildFnNameDict(fns)
|
||||
{functions: fns, fnNameDict: dict}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,15 @@ let dispatch = (call: InternalExpressionValue.functionCall, environment, chain):
|
|||
|
||||
/*
|
||||
If your dispatch is too big you can divide it into smaller dispatches and pass the call so that it gets called finally.
|
||||
|
||||
The final chain(call) invokes the builtin default functions of the interpreter.
|
||||
|
||||
Via chain(call), all MathJs operators and functions are available for string, number , boolean, array and record
|
||||
.e.g + - / * > >= < <= == /= not and or sin cos log ln concat, etc.
|
||||
|
||||
// See https://mathjs.org/docs/expressions/syntax.html
|
||||
// See https://mathjs.org/docs/reference/functions.html
|
||||
|
||||
Remember from the users point of view, there are no different modules:
|
||||
// "doSth( constructorType1 )"
|
||||
// "doSth( constructorType2 )"
|
||||
|
|
|
@ -18,6 +18,5 @@ let mathBindings: Bindings.t =
|
|||
->E.A2.fmap(((name, v)) => (name, ReducerInterface_InternalExpressionValue.IEvNumber(v)))
|
||||
->Bindings.fromArray
|
||||
|
||||
//TODO: This should be in a different place.
|
||||
let makeBindings = (previousBindings: Bindings.t): Bindings.t =>
|
||||
previousBindings->Bindings.merge(mathBindings)
|
||||
|
|
Loading…
Reference in New Issue
Block a user