top of page

The Rule Engine Flex-Evaluator

The flexible evaluator of the Rule Engine powers the ability of a user to freely use mathematical modelling language syntax to define business rules. We empower business users as "power users" to use the rule chains with mathematical functions and pseudo code.

In this article, we shall understand the different types of syntax and usage capabilities for this engine.


If you are here, you are probably using the Nighthack Rule Engine in it's Core or Academic Evaluator form. Please ensure, you have the power-user modules enabled and access rights / permissions to the test system in place.

Overview of Capabilities

Simple Arithmetic

The standard BODMAS with any expression is supported out of the box. The evaluator understands precedence order and using parentheses to group expressions to ensure proper evaluation.

Rule Expression Input: '5 + 3 * 2'
#=> 11
Rule Expression Input:  '(5 + 3) * 2'
#=> 16

Higher Arithmetic

The following additional functionalities are available for usage:

^ - exponential power

'(2 ^ 3) * 2'
#=> 16

% - modulus

#=> 0
#=> 1


SIN, COS, TAN - use only if setting up a complex calculation system.

Do not use in business rules unless calculating for architecture.


& > Logical AND of two values in binary (do not use for Business rules)

#=> 2

| > Logical OR of two values in binary (do not use for Business rules)

#=> 20

IF > Conditional Evaluation

if (condition, <Do this on true>, <Do this on false>)

if (13>1, 4, 0)
#=> 4

Numeric - Special

MAX(value1, value2, value3, value4)

#=> 65

MIN(value1, value2, value3, value4)

#=> 2

SUM(value1, value2, value3)

#=> 14

AVG(value1, value2, value3)

#=> 19

COUNT(value1, value2, value3, value4) : Count number of values passed to function

#=> 5

ROUNDING OF NUMBERS : Consists of Rounding up and Rounding down

ROUNDDOWN : Floor operator

ROUNDUP : Roof operator

#=> 12

#=> 13

Mixing and matching for decisions

Combine IF with calculations

if ((13*0.25)>1, 13*0.25, 2.5)
#=> 3.25

Other examples can be enabled based on use case and type of rules you will use

13 views0 comments


bottom of page