summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJake Zerrer <him@jakezerrer.com>2025-12-01 15:43:49 -0500
committerJake Zerrer <him@jakezerrer.com>2025-12-01 15:44:17 -0500
commitf940b2f1452b0cccfbb501c14c7f348e5dc1d2e6 (patch)
tree8b76af197cb25ca54db4884bda0a37b1050dceb0
parent2d1418040bac7bec0ebac8b9c6d89ced3af7faeb (diff)
Housekeeping
-rw-r--r--src/unheard/cycles.clj34
1 files 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.