   (reduce (fn [D i] (.op ds i D)) D idxs))
 
 (defn chain-end [ds D i j]
-  (let [step (fn [E]
-               (let [E* (walk ds E j)]
-                 (cond
-                   (nil? E*) E
-                   (= E E*) E
-                   (= D E*) nil
-                   :else (recur (walk ds E j i)))))]
+  (letfn [(step [E]
+                (let [E* (walk ds E j)]
+                  (cond
+                    (nil? E*) E
+                    (= E E*) E
+                    (= D E*) nil
+                    :else (recur (walk ds E j i)))))]
     (step (walk ds D i))))
 
 (defn boundary-chambers [ds D i j k]
-  (let [a (fn [D] (walk ds D i))
-        b (fn [D] (chain-end ds D j k))]
+  (letfn [(a [D] (walk ds D i))
+          (b [D] (chain-end ds D j k))]
     (iterate-cycle [a b] D)))
 
 (defn max-curvature [ds]

(def sets (new CombineTiles octagon))

(def syms (mapcat syms-for sets))

  (if (.isNegative (max-curvature ds))
    []
    (new DefineBranching2d ds 3 2 Whole/ZERO)))

(def template
  (new DSymbol (str "1.1:60:"
