diff --git a/src/arboretum/dengine/node.clj b/src/arboretum/dengine/node.clj index 2891041..486acc9 100644 --- a/src/arboretum/dengine/node.clj +++ b/src/arboretum/dengine/node.clj @@ -32,10 +32,17 @@ (defn make-node "Make a node. TODO: these wrapper functions will probably disappear once I'm more comfortable with the architecture." - ([feature ^Boolean colour ^String fragment] - (make-node feature colour fragment nil)) - ([feature ^Boolean colour ^String fragment children ] - (NodeImpl. feature colour fragment children))) + ([feature-id ^Boolean colour ^String fragment] + (make-node feature-id colour fragment nil)) + ([feature-id ^Boolean colour ^String fragment children ] + (if (and (find-feature-for @!kb feature-id) + (every? #(satisfies? Node %) children)) + (NodeImpl. feature-id colour fragment children) + (throw (ex-info "Unexpected item passed as child node" + {:feature-id feature-id + :colour colour + :fragment fragment + :children children}))))) ;; Here's the algorithm as published in A Graphical Inference Mechanism, ;; but it's not real Interlisp code, and I remember there being at least