modify lambda
This commit is contained in:
parent
eba087329f
commit
c5e08cfdb6
|
@ -91,7 +91,7 @@ let rec reduceExpression = (expression: t, bindings: T.bindings): result<express
|
|||
switch valueList {
|
||||
| list{EvCall(fName), ...args} => (fName, args->Belt.List.toArray)->BuiltIn.dispatch
|
||||
// "(lambda(x=>internal) param)"
|
||||
| list{EvLambda(parameters, internal), ...args} =>
|
||||
| list{EvLambda((parameters, internal)), ...args} =>
|
||||
applyParametersToLambda(internal, parameters, args)
|
||||
| _ => valueList->Belt.List.toArray->ExpressionValue.EvArray->Ok
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ let rec reduceExpression = (expression: t, bindings: T.bindings): result<express
|
|||
let rec reduceExpandedExpression = (expression: t): result<expressionValue, 'e> =>
|
||||
switch expression {
|
||||
| T.EList(list{T.EValue(EvCall("$lambda")), T.EParameters(parameters), functionDefinition}) =>
|
||||
EvLambda(parameters, functionDefinition->castExpressionToInternalCode)->Ok
|
||||
EvLambda((parameters, functionDefinition->castExpressionToInternalCode))->Ok
|
||||
| T.EValue(value) => value->Ok
|
||||
| T.EList(list) => {
|
||||
let racc: result<list<expressionValue>, 'e> = list->Belt.List.reduceReverse(Ok(list{}), (
|
||||
|
|
|
@ -14,7 +14,7 @@ type rec expressionValue =
|
|||
| EvBool(bool)
|
||||
| EvCall(string) // External function call
|
||||
| EvDistribution(GenericDist_Types.genericDist)
|
||||
| EvLambda(array<string>, internalCode)
|
||||
| EvLambda((array<string>, internalCode))
|
||||
| EvNumber(float)
|
||||
| EvRecord(Js.Dict.t<expressionValue>)
|
||||
| EvString(string)
|
||||
|
@ -29,7 +29,7 @@ let rec toString = aValue =>
|
|||
switch aValue {
|
||||
| EvBool(aBool) => Js.String.make(aBool)
|
||||
| EvCall(fName) => `:${fName}`
|
||||
| EvLambda(parameters, _internalCode) => `lambda(${Js.Array2.toString(parameters)}=>internal)`
|
||||
| EvLambda((parameters, _internalCode)) => `lambda(${Js.Array2.toString(parameters)}=>internal)`
|
||||
| EvNumber(aNumber) => Js.String.make(aNumber)
|
||||
| EvString(aString) => `'${aString}'`
|
||||
| EvSymbol(aString) => `:${aString}`
|
||||
|
@ -60,7 +60,7 @@ let toStringWithType = aValue =>
|
|||
| EvBool(_) => `Bool::${toString(aValue)}`
|
||||
| EvCall(_) => `Call::${toString(aValue)}`
|
||||
| EvDistribution(_) => `Distribution::${toString(aValue)}`
|
||||
| EvLambda(_parameters, _internalCode) => `Lambda::${toString(aValue)}`
|
||||
| EvLambda((_parameters, _internalCode)) => `Lambda::${toString(aValue)}`
|
||||
| EvNumber(_) => `Number::${toString(aValue)}`
|
||||
| EvRecord(_) => `Record::${toString(aValue)}`
|
||||
| EvString(_) => `String::${toString(aValue)}`
|
||||
|
|
Loading…
Reference in New Issue
Block a user