 (defn m [ds i j D]
   (let [v (v ds i j D)
         r (r ds i j D)]
-    (when (and v r) (* v r))))
+    (if (and v r) (* v r))))
 
 (defn chain-end [ds D i j]
   "Returns the result of alternately applying operators indexed i and j,

                                               [D (s ds1 i D)])
                                             (for [D (elements ds2)]
                                               [(+ s1 D)
                                                (when-let [E (s ds2 i D)]
                                                  (+ s1 E))])))]))
          vs (into {} (for [i (range d)]
                        [i (into {} (concat (for [D (elements ds1)]

  (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
