                [[:plus a [:plus b c]]] [:plus [:plus a b] c]
                [[:minus a [:minus b c]]] [:minus [:minus a b] c]
                [[:times a [:times b c]]] [:times [:times a b] c]
-               ;; times to the right
-               ;;[[:times [:times a b] c]] [:times a [:times b c]]
-               ;;[[:plus [:plus a b] c]] [:plus a [:plus b c]]
                ;; always move numbers to the left
                [[:plus (a :guard not-number?) (b :guard number?)]] [:plus b a]
                [[:minus (a :guard not-number?) (b :guard number?)]] [:minus b a]

               [x] x
               ))

(defn expand-tree
  [expr]
  (if (expression/non-terminal? expr)
    (expand (expression/make-expression (first expr) (map expand-tree (rest expr))))
    expr))

(defn expand-full
  [expr]
  (let [new-exp (expand-tree expr)]
    (if (= expr new-exp)
      new-exp
      (recur new-exp))))
;;;; Not for distribution.

(ns algebolic.expression.algebra
  "This namespace implements some basic computer algebra operations on algebolic expressions. And by 'basic'
  I really mean basic. The functions here make no attempt at being a complete computer algebra system, but
  rather offer a few useful transformations that can be used both in the EA, and also by hand for
  understanding expressions."
  (:require [algebolic.expression.core :as expression]
            [clojure.core.match :as match]
            [clojure.walk :as walk]
