From dc923f3e1add752f9c1b53390b276100cbad7ed6 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Wed, 8 Jul 2020 09:21:35 -0500 Subject: added noise --- gtwiwtg.lisp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gtwiwtg.lisp') 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) -- cgit v1.2.3