                       (ops ds)
                       (vs ds))
                 w))
-
-(deftest gluing
-  (is (= (dsglue (DSymbol. 0 0 {} {}) 2 1 2)
-         (DSymbol. 2 2 {2 {1 2 2 1}} {}))))
-
-;; General D-symbol functions
-
-(defn- ops [ds]
-  (into {} (for [i (indices ds)]
-             [i (into {} (for [D (elements ds)
-                               :when (s ds i D)]
-                           [D (s ds i D)]))])))
-
-(defn- vs [ds]
-  (into {} (for [i (indices ds)
-                 :when (index? ds (inc i))]
-             [i (into {} (for [D (elements ds)
-                               :when (v ds i (inc i) D)]
-                           [D (v ds i (inc i) D)]))])))
-
-(defn size [ds] (count (elements ds)))
-
-(defn dim [ds] (dec (count (indices ds))))
 
 (defn walk [ds D & idxs]
   "Returns the result of applying the D-symbol operators on ds with the

  (indices [ds] (iterator-seq (.indices ds)))
  (s [ds i D] (when (.definesOp ds i D) (.op ds i D)))
  (v [ds i j D] (when (.definesV ds i j D) (.v ds i j D))))

(deftype DSymbol [dim size s# v#]
  IDSymbol

               (= (ops self) (ops other))
               (= (vs self) (vs other)))))


;; === Functions for IDSymbol instances

(defn size [ds] (count (elements ds)))

(defn dim [ds] (dec (count (indices ds))))

(defmethod print-method DSymbol [ds ^Writer w]
  (print-method (list (symbol "DSymbol.")
                      (dim ds)
