Created
November 13, 2017 20:31
-
-
Save WilliamParker/a3adaa3db730229bc01586009bb7178a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clara.test-rules> (clara.rules/defrule lost-game | |
[?ships <- (acc/count) :from [Ship]] | |
[?destroyed <- (acc/count) :from [Destroyed]] | |
[:test (= ?ships ?destroyed)] | |
=> | |
(insert! (->Loser))) | |
#'clara.test-rules/lost-game | |
clara.test-rules> (-> (mk-session [lost-game]) .rulebase :alpha-roots (get Ship)) | |
({:env nil, | |
:children | |
({:id 2, | |
:accum-condition {:accumulator (clara.rules.accumulators/count), :from {:type clara.test_rules.Ship, :constraints []}}, | |
:accumulator | |
{:initial-value 0, | |
:reduce-fn #function[clara.rules.accumulators/count/fn--16091], | |
:combine-fn #function[clojure.core/+], | |
:convert-return-fn #function[clojure.core/identity], | |
:retract-fn #function[clara.rules.accumulators/count/fn--16093]}, | |
:result-binding :?ships, | |
:children | |
({:id 3, | |
:accum-condition {:accumulator (clara.rules.accumulators/count), :from {:type clara.test_rules.Destroyed, :constraints []}}, | |
:accumulator | |
{:initial-value 0, | |
:reduce-fn #function[clara.rules.accumulators/count/fn--16091], | |
:combine-fn #function[clojure.core/+], | |
:convert-return-fn #function[clojure.core/identity], | |
:retract-fn #function[clara.rules.accumulators/count/fn--16093]}, | |
:result-binding :?destroyed, | |
:children | |
({:id 4, | |
:production | |
{:ns-name clara.test-rules, | |
:lhs | |
[{:accumulator (clara.rules.accumulators/count), :from {:type clara.test_rules.Ship, :constraints []}, :result-binding :?ships} | |
{:accumulator (clara.rules.accumulators/count), :from {:type clara.test_rules.Destroyed, :constraints []}, :result-binding :?destroyed} | |
{:constraints [(= ?ships ?destroyed)]}], | |
:rhs (do (insert! (->Loser))), | |
:name "clara.test-rules/lost-game"}, | |
:rhs #function[clara.test-rules/eval17812/fn--17813]}), | |
:binding-keys #{}, | |
:new-bindings #{}}), | |
:binding-keys #{}, | |
:new-bindings #{}}), | |
:activation #function[clara.test-rules/eval17828/fn--17829]}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment