⚙️ Fournit un opérateur d'inégalité

pull/47/head
Laurent Bossavit 2017-09-07 23:26:31 +02:00
parent f8624916be
commit 1426af4f6b
2 changed files with 4 additions and 3 deletions

View File

@ -18,7 +18,7 @@ Comparison -> Comparable _ ComparisonOperator _ Comparable {% d => ({
Comparable -> (int | CalcExpression | Variable | Constant) {% d => d[0][0] %}
ComparisonOperator -> ">" | "<" | ">=" | "<=" | "="
ComparisonOperator -> ">" | "<" | ">=" | "<=" | "=" | "!="
NegatedVariable -> "≠" _ Variable {% d => ({category: 'negatedVariable', variable: d[2] }) %}

View File

@ -201,12 +201,13 @@ let treat = (rules, rule) => rawNode => {
'<=': 'lte',
'>': 'gt',
'>=': 'gte',
'=': 'equals'
'=': 'equals',
'!=': 'equals'
}[node.operator],
explanation = R.map(R.curry(evaluateNode)(situation,parsedRules),node.explanation),
value1 = explanation[0].nodeValue,
value2 = explanation[1].nodeValue,
operatorFunction = R[operatorFunctionName],
operatorFunction = operatorFunctionName == "!=" ? (a => b => !R.equals(a,b)) : R[operatorFunctionName],
nodeValue = value1 == null || value2 == null ?
null
: operatorFunction(value1, value2)