Minor cleanup
This commit is contained in:
parent
173c17e13d
commit
6f25fca814
|
@ -274,8 +274,7 @@ module Matcher = {
|
||||||
|
|
||||||
module Registry = {
|
module Registry = {
|
||||||
let _findExactMatches = (r: registry, fnName: string, args: array<internalExpressionValue>) => {
|
let _findExactMatches = (r: registry, fnName: string, args: array<internalExpressionValue>) => {
|
||||||
let functionMatchPairs =
|
let functionMatchPairs = r.functions->E.A2.fmap(l => (l, Function.match(l, fnName, args)))
|
||||||
r.functions->E.A2.fmap(l => (l, Function.match(l, fnName, args)))
|
|
||||||
let fullMatch = functionMatchPairs->E.A.getBy(((_, match)) => Match.isFullMatch(match))
|
let fullMatch = functionMatchPairs->E.A.getBy(((_, match)) => Match.isFullMatch(match))
|
||||||
fullMatch->E.O.bind(((fn, match)) =>
|
fullMatch->E.O.bind(((fn, match)) =>
|
||||||
switch match {
|
switch match {
|
||||||
|
@ -416,7 +415,8 @@ module Registry = {
|
||||||
r.functions->E.A2.fmap(fn => fn.examples->E.A2.fmap(example => (fn, example)))->E.A.concatMany
|
r.functions->E.A2.fmap(fn => fn.examples->E.A2.fmap(example => (fn, example)))->E.A.concatMany
|
||||||
|
|
||||||
let buildFnNameDict = (r: array<function>): fnNameDict => {
|
let buildFnNameDict = (r: array<function>): fnNameDict => {
|
||||||
let allDefinitionsWithFns = r
|
let allDefinitionsWithFns =
|
||||||
|
r
|
||||||
->E.A2.fmap(fn => fn.definitions->E.A2.fmap(definitions => (fn, definitions)))
|
->E.A2.fmap(fn => fn.definitions->E.A2.fmap(definitions => (fn, definitions)))
|
||||||
->E.A.concatMany
|
->E.A.concatMany
|
||||||
let functionsWithFnNames =
|
let functionsWithFnNames =
|
||||||
|
|
|
@ -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.
|
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.
|
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
|
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.
|
.e.g + - / * > >= < <= == /= not and or sin cos log ln concat, etc.
|
||||||
|
|
||||||
// See https://mathjs.org/docs/expressions/syntax.html
|
// See https://mathjs.org/docs/expressions/syntax.html
|
||||||
// See https://mathjs.org/docs/reference/functions.html
|
// See https://mathjs.org/docs/reference/functions.html
|
||||||
|
|
||||||
Remember from the users point of view, there are no different modules:
|
Remember from the users point of view, there are no different modules:
|
||||||
// "doSth( constructorType1 )"
|
// "doSth( constructorType1 )"
|
||||||
// "doSth( constructorType2 )"
|
// "doSth( constructorType2 )"
|
||||||
|
|
|
@ -18,6 +18,5 @@ let mathBindings: Bindings.t =
|
||||||
->E.A2.fmap(((name, v)) => (name, ReducerInterface_InternalExpressionValue.IEvNumber(v)))
|
->E.A2.fmap(((name, v)) => (name, ReducerInterface_InternalExpressionValue.IEvNumber(v)))
|
||||||
->Bindings.fromArray
|
->Bindings.fromArray
|
||||||
|
|
||||||
//TODO: This should be in a different place.
|
|
||||||
let makeBindings = (previousBindings: Bindings.t): Bindings.t =>
|
let makeBindings = (previousBindings: Bindings.t): Bindings.t =>
|
||||||
previousBindings->Bindings.merge(mathBindings)
|
previousBindings->Bindings.merge(mathBindings)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user