From f940b2f1452b0cccfbb501c14c7f348e5dc1d2e6 Mon Sep 17 00:00:00 2001 From: Jake Zerrer Date: Mon, 1 Dec 2025 15:43:49 -0500 Subject: Housekeeping --- src/unheard/cycles.clj | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/unheard/cycles.clj b/src/unheard/cycles.clj index eb53c57..29cad91 100644 --- a/src/unheard/cycles.clj +++ b/src/unheard/cycles.clj @@ -136,7 +136,11 @@ (= :rep (:type node)) ;; Replication doesn't change the cycle count - it just subdivides time ;; The parent sees the same cycle count as the child - (compute-cycle (:v node)))) + (compute-cycle (:v node)) + + :else + (throw (ex-info "Unknown node type in compute-cycle" + {:node node :type (:type node)})))) (defn unfold-node [node start end iteration] (let [duration (- end start)] @@ -178,12 +182,12 @@ ;; rate 1/2 means fit 0.5x cycles (half a cycle) num-child-cycles (* ratio child-base-cycle) child-cycle-duration (/ duration num-child-cycles)] - (vec (mapcat (fn [i] - (unfold-node child - (+ start (* i child-cycle-duration)) - (+ start (* (inc i) child-cycle-duration)) - i)) - (range num-child-cycles)))) + (mapcat (fn [i] + (unfold-node child + (+ start (* i child-cycle-duration)) + (+ start (* (inc i) child-cycle-duration)) + i)) + (range num-child-cycles))) (= :elongate (:type node)) ;; Elongate just wraps a child - unfold the child with the same time bounds @@ -194,12 +198,16 @@ (let [times (:times node) child (:v node) slice-duration (/ duration times)] - (vec (mapcat (fn [i] - (unfold-node child - (+ start (* i slice-duration)) - (+ start (* (inc i) slice-duration)) - iteration)) - (range times))))))) + (mapcat (fn [i] + (unfold-node child + (+ start (* i slice-duration)) + (+ start (* (inc i) slice-duration)) + iteration)) + (range times))) + + :else + (throw (ex-info "Unknown node type in unfold-node" + {:node node :type (:type node)}))))) (defn unfold "Unfolds a pattern tree into concrete time intervals. -- cgit v1.2.3