 ;; The token that triggered a rule to fire.
 (def ^:dynamic *rule-context* nil)
 
-(declare print-memory)
-
 (defn fire-rules* 
    "Fire rules for the given nodes."
    [rulebase nodes transient-memory transport]

(defprotocol IRuleSource
  (load-rules [source]))

(defrecord Condition [type constraints binding-keys activate-fn text])

;; Record containing one or more test expressions to evaluate.
(defrecord Test [test-fn text])

(defrecord Production [lhs rhs])

(defrecord Query [params lhs binding-keys])

(defrecord Rulebase [alpha-roots beta-roots productions queries production-nodes query-nodes node-to-id id-to-node]
  IRuleSource
  (load-rules [this] this)) ; A rulebase can be viewed as a rule loader; it simply loads itself.

(defrecord Token [facts bindings])

;; A working memory element
(defrecord Element [fact bindings])

;; Token with no bindings, used as the root of beta nodes.

    (retract-tokens transport memory (:children node) 
                    [(->Token new-facts new-bindings)])))

(defn- send-accumulated 
  "Helper function to send the result of an accumulated value to the node's children."
  [node accumulator token result fact-bindings transport memory]
  (let [converted-result ((get-in accumulator [:definition :convert-return-fn]) result)
        new-bindings (merge (:bindings token) 
                            fact-bindings
