Rulex
Rulex allow you to define rules just as you define functions, a simple macro wrapper add the needed code in order to not match the same rule twice. It creates a recursive function apply_rules
which returns the accumulator when no rule match.
Example usage :
iex> defmodule MyRules do
...> use Rulex
...> defrule my_first_rule("y"<>_,string_desc), do:
...> [:starts_with_y|string_desc]
...> defrule my_second_rule("ya"<>_,string_desc), do:
...> [:starts_with_ya|string_desc]
...> defrule my_third_rule("b"<>_,string_desc), do:
...> [:starts_with_b|string_desc]
...> end
...> MyRules.apply_rules("yahoo",[])
[:starts_with_ya,:starts_with_y]