aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <cbeok@protonmail.com>2020-07-08 09:21:35 -0500
committerColin Okay <cbeok@protonmail.com>2020-07-08 09:21:35 -0500
commitdc923f3e1add752f9c1b53390b276100cbad7ed6 (patch)
tree7fc5f5fb1e8e218e4394492e2e1d27c98e911be3
parentffd38554dbaf27a025e0b0704c36d023fa64d228 (diff)
added noise
-rw-r--r--gtwiwtg.lisp11
-rw-r--r--package.lisp1
2 files changed, 12 insertions, 0 deletions
diff --git a/gtwiwtg.lisp b/gtwiwtg.lisp
index a0e74e7..35b834c 100644
--- a/gtwiwtg.lisp
+++ b/gtwiwtg.lisp
@@ -82,6 +82,17 @@ the values passed as ARGS looped forever."
(values (car state) (cdr state))
(values (car args) (copy-list (cdr args)))))))
+
+(defun noise (&optional (arg 1.0))
+ "Creates a generator that produces an infinite series of random
+ numbers that are the result of calling (RANDOM ARG)."
+ (make-instance 'generator!
+ :state nil
+ :next-p-fn (constantly t)
+ :next-fn (lambda (state)
+ (declare (ignore state))
+ (values (random arg) nil))))
+
;;; Some utilities
(defun all-different (things)
diff --git a/package.lisp b/package.lisp
index 6f853bd..40452be 100644
--- a/package.lisp
+++ b/package.lisp
@@ -6,6 +6,7 @@
#:times
#:seq
#:repeater
+ #:noise
#:yield-to!
#:map!
#:filter!