Skip to content

Commit

Permalink
use range-series to compute a range with sampling rate changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dgtized committed Aug 1, 2024
1 parent b682540 commit eef3ea5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/shimmers/common/sequence.cljc
Original file line number Diff line number Diff line change
@@ -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."
Expand Down Expand Up @@ -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)))))

0 comments on commit eef3ea5

Please sign in to comment.