LFE Rule Engine library
Rule Engine is a small subset of LISP aimed to handle user input (S-expessions) returning true if expression evaluates to true, false if it evalues to false or nil if it cannot be evaluated. It supports handling surrounding context and supposed to be extensible.
More to be done soon!
See tests for usage info:
Using LFE:
;; Check if S-expression conforms Rule Engine
(== (rule-engine:check '(or true false) 'boolexpr?) 'true)
(== (rule-engine:check '(in true or) 'expr?) 'false)
;; Evaluate S-expression using Rule Engine
(== (rule-engine:evaluate '(or true false)) 'true)
(== (rule-engine:evaluate '(and true false (in 3 (1 2 3)) 'false)))
The same using Erlang:
% Check if S-expression conforms Rule Engine
'rule-engine':check(['or','true','false'], 'boolexpr?') == true.
'rule-engine':check(['in','true','or'], 'expr?') == false.
% Evaluate S-expression using Rule Engine
'rule-engine':evaluate(['or','true','false']) == true.
'rule-engine':evaluate(['and','true','false',['in',3,[1,2,3]]]) == false.
$ rebar3 compile
$ rebar3 eunit
Copyright © 2017, Sergey Sobko
MIT License