summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2013-12-11 22:49:32 -0500
committerDavid Thompson <dthompson2@worcester.edu>2013-12-11 22:49:32 -0500
commitdf45474ac007467d5f837dfc6444e460b5b4d765 (patch)
treecfda18f80c2a9988a3fc8df8fa450ccca893d73b
parentbc66a865445ae18224564ae257a146dd7a529962 (diff)
Add signal-do procedure.
* 2d/signals.scm (signal-do): New procedure.
-rw-r--r--2d/signals.scm14
1 files changed, 13 insertions, 1 deletions
diff --git a/2d/signals.scm b/2d/signals.scm
index 04de9c0..85cc5af 100644
--- a/2d/signals.scm
+++ b/2d/signals.scm
@@ -51,7 +51,8 @@
signal-and
signal-or
signal-when
- signal-unless))
+ signal-unless
+ signal-do))
;;;
;;; Signals
@@ -281,3 +282,14 @@ is never true."
#:transformer (lambda (value prev from)
(signal-ref consequent))
#:connectors (list predicate consequent)))
+
+(define (signal-do proc signal)
+ "Create a new signal that applies PROC with incoming values from
+SIGNAL. The value of the new signal will always be the value of
+SIGNAL. This signal is a convenient way to apply a side-effect to a
+signal value."
+ (make-signal
+ #:transformer (lambda (value prev from)
+ (proc value)
+ value)
+ #:connectors (list signal)))