   (indices [_] (range 0 (inc dim)))
   (s [_ i D] ((or (s# i) {}) D))
   (v [ds i j D]
-     (when (and (element? ds D) (index? ds i) (index? ds j))
+     (if (and (element? ds D) (index? ds i) (index? ds j))
        (cond (= j (inc i)) ((or (v# i) {}) D)
              (= j (dec i)) ((or (v# j) {}) D)
              (= j i) 1

;; === Factories for DSymbol instances

(defn- parse-numbers [str]
  (when (and str (< 0 (count (s/trim str))))
    (map #(Integer/parseInt %) (-> str s/trim (s/split #"\s+")))))

(defn- parse-number-lists [str]
  (when str
    (map parse-numbers (-> str s/trim (s/split #",")))))

(defn- pairs [data free]
  (when (seq free)
    (let [pair [(first free) (first data)]
          rest-free (remove (set pair) free)]
      (lazy-seq (cons pair (pairs (rest data) rest-free))))))

  (elements [ds] (iterator-seq (.elements ds)))
  (index? [ds i] (.hasIndex ds i))
  (indices [ds] (iterator-seq (.indices ds)))
  (s [ds i D] (if (.definesOp ds i D) (.op ds i D)))
  (v [ds i j D] (if (.definesV ds i j D) (.v ds i j D))))


;; === Helper functions
