   (if (string? x) (get env x x) x))
 
 (defn partial-eval
-  [env expr]
+  [env e]
   (walk/postwalk
-    (comp optimize-mul optimize-add (partial replace-var env))
-    expr))
+    (comp optimize-mul optimize-add #(replace-var env %))
+    e))
 
 ;; ----------------------------------------------------------------------------
 

      )))

(defn- optimize-add [e]
  (cond
    (add? e) (optimize-op e + 0)
    :else e))

(defn- optimize-mul [e]
  (cond
    (mul? e) (if (some #{0} e) (cst 0) (optimize-op e * 1))
    :else e))

(defn optimize
  [e]
  (walk/postwalk
    (comp optimize-mul optimize-add)
    e))


;; ----------------------------------------------------------------------------

(defn add [& args] (into [:add] args))
(defn mul [& args] (into [:mul] args))

(defn rator [e] (first e))
(defn rands [e] (rest e))

(defn cst? [n] (number? n))
(defn sym? [v] (string? v))
(defn op? [e] (vector? e))
(defn add? [e] (and (op? e) (= (rator e) :add)))
(defn mul? [e] (and (op? e) (= (rator e) :mul)))


;; ----------------------------------------------------------------------------
