From eef3ea56d464d30644f288f418c3fb0489221120 Mon Sep 17 00:00:00 2001 From: Charles Comstock Date: Thu, 1 Aug 2024 18:04:58 -0500 Subject: [PATCH] use range-series to compute a range with sampling rate changes --- src/shimmers/common/sequence.cljc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/shimmers/common/sequence.cljc b/src/shimmers/common/sequence.cljc index afd5f1f6..adc90c91 100644 --- a/src/shimmers/common/sequence.cljc +++ b/src/shimmers/common/sequence.cljc @@ -1,4 +1,5 @@ -(ns shimmers.common.sequence) +(ns shimmers.common.sequence + (:require [clojure.math :as math])) (defn index-of "Find the index of a particular value in coll." @@ -218,3 +219,12 @@ (drop-while (complement pred))) ([pred coll] (drop-while (complement pred) coll))) + +(defn range-series [start end rate-f] + (take-while (fn [t] (<= t end)) + (iterate (fn [t] (+ t (rate-f t))) + start))) + +(comment (range-series 0 1 (fn [t] (max 0.01 (* 0.1 t)))) + (range-series 0 1 (fn [t] (* 0.1 (math/exp (* (- 0.1) t))))) + (range-series 0 100 (fn [t] (math/exp (* 0.02 t)))))