                  [plan node] (add-flow plan (->FilterMap nodes filter-map-fun))]
              [plan [node] vars]))))
 
+(comment
+  (let [plan empty-flow-plan
+        [plan nodes-a vars-a] (recall->nodes plan (Recall. :known&pretended (->edge 'x 'y)))
+        [plan nodes-b vars-b] (compute->nodes plan nodes-a vars-a (Compute. (->Let 'z '[x y] "x + y")))]
+    [plan nodes-a nodes-b vars-a vars-b])
+
+
+  (let [plan empty-flow-plan
+        [plan nodes-a vars-a] (recall->nodes plan (Recall. :known&pretended (->edge 'x 'y)))
+        res (compute->nodes plan nodes-a vars-a (Compute. (->Let 'z '[w x y] "w + x + y")))]
+    res)
+
+  (let [plan empty-flow-plan
+        [plan nodes-a vars-a] (recall->nodes plan (Recall. :known&pretended (->edge 'x 'y)))
+        [plan nodes-b vars-b] (compute->nodes plan nodes-a vars-a (Compute. (->When '[x y] "x > y")))]
+    [plan nodes-a nodes-b vars-a vars-b])
+  )
+
 (defn computes->nodes [plan nodes vars computes]
     (loop [orig-nodes nodes
            plan plan


  (deffact edge "[x] has an edge to [y]")
  (deffact connected "[x] is connected to [y]")

  ;; [x] has an edge to [y]
  ;; [y] is connected to [z]

           computes-applied computes-applied
           computes-unapplied []]
      (if-let [[compute & computes-remaining] (seq computes-remaining)]
        (if-let [[new-plan new-nodes new-vars] (compute->nodes plan nodes vars compute)]
          (recur orig-nodes new-plan new-nodes new-vars computes-remaining (conj computes-applied compute) computes-unapplied)
          (recur orig-nodes plan nodes vars computes-remaining computes-applied (conj computes-unapplied compute)))
        (if (= nodes orig-nodes)
          [plan nodes vars (set computes-applied)]
          (recur nodes plan nodes vars computes-unapplied computes-applied [])))))

(comment
  (let [plan empty-flow-plan
        [plan nodes-a vars-a] (recall->nodes plan (Recall. :known&pretended (->edge 'x 'y)))
        [plan nodes-b vars-b computes-applied] (computes->nodes plan nodes-a vars-a [(Compute. (->When '[x z] "x > z"))
                                                                                     (Compute. (->Let 'z '[x y] "x + y"))
                                                                                     (Compute. (->Let 'z '[w x] "a + x"))])]
    [plan nodes-b vars-b computes-applied])
  )

(defn output->nodes [plan nodes vars {:keys [memory pattern]}]
  (assert (every? (set vars) (pattern->vars pattern)))
  (let [[plan output-node] (add-flow plan (FilterMap. nodes (pattern->constructor pattern vars)))
        plan (add-output plan output-node memory)]
    plan))

(comment
  (let [plan empty-flow-plan
        [plan nodes-a vars-a] (recall->nodes plan (Recall. :known&pretended (->edge 'x 'y)))
        [plan nodes-b vars-b computes-applied] (computes->nodes plan nodes-a vars-a [(Compute. (->When '[x z] "x > z"))
                                                                                     (Compute. (->Let 'z '[x y] "x + y"))
                                                                                     (Compute. (->Let 'z '[w x] "a + x"))])
        plan (output->nodes plan nodes-b vars-b (Output. :remembered (->connected 'x 'y)))]
    plan)
  )

(defn join->nodes [plan nodes-a vars-a computes-applied-a nodes-b vars-b computes-applied-b]
  (let [key-vars (intersection (set vars-a) (set vars-b))
