Created
November 13, 2017 20:35
-
-
Save WilliamParker/347ba6ca3f7e0afc2c9f183e0731111e 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 (tu/join-filter-equals ?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 1, | |
: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 2, | |
: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 3, | |
:test #function[clara.test-rules/eval17847/fn--17848], | |
: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 [(clara.tools.testing-utils/join-filter-equals ?ships ?destroyed)]}], | |
:rhs (do (insert! (->Loser))), | |
:name "clara.test-rules/lost-game"}, | |
:rhs #function[clara.test-rules/eval17843/fn--17844]})}), | |
:binding-keys #{}, | |
:new-bindings #{}}), | |
:binding-keys #{}, | |
:new-bindings #{}}), | |
:activation #function[clara.test-rules/eval17859/fn--17860]}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment