diff options
author | Colin Okay <cbeok@protonmail.com> | 2020-07-08 09:21:35 -0500 |
---|---|---|
committer | Colin Okay <cbeok@protonmail.com> | 2020-07-08 09:21:35 -0500 |
commit | dc923f3e1add752f9c1b53390b276100cbad7ed6 (patch) | |
tree | 7fc5f5fb1e8e218e4394492e2e1d27c98e911be3 /gtwiwtg.lisp | |
parent | ffd38554dbaf27a025e0b0704c36d023fa64d228 (diff) |
added noise
Diffstat (limited to 'gtwiwtg.lisp')
-rw-r--r-- | gtwiwtg.lisp | 11 |
1 files changed, 11 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) |