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 +++++++++++ package.lisp | 1 + 2 files changed, 12 insertions(+) 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! -- cgit v1.2.3