oracle-samples / clara-rules

Forward-chaining rules in Clojure(Script)

Home Page:http://www.clara-rules.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does Clara support these Drools behaviors?

victorrodrigueznadq opened this issue · comments

Does clara support these drools behaviors?

Screenshot 2024-05-20 at 6 24 55 AM

Screenshot 2024-05-20 at 6 25 20 AM

@victorrodrigueznadq,
Clara supports Conditional negation, using the drools example as inspiration we'd arrive at a rule like:

(r/defrule not-a-bus
  [:not [Bus]]
  =>
  (r/insert (->NoBusses)))

or

(r/defrule no-red-busses
  [:not [Bus (= color "red")]]
  =>
  (r/insert (->NoRedBusses)))

Clara also supports the idea of exists as well, :exists is a syntactic sugar around a basic accumulator exists. Used something like:

(r/defrule got-bus
  [:exists [Bus]]
  =>
  (r/insert (->BusExists)))

or

 (r/defrule got-red-bus
  [:exists [Bus (= color "red")]]
  =>
  (r/insert (->RedBusExists)))