summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-02-10 21:59:10 -0500
committerDavid Thompson <dthompson2@worcester.edu>2016-02-10 22:01:38 -0500
commit5571463e79247d6cb338a015e5bbf94d4bafde44 (patch)
tree98cc33f34a40edb4fe76730f2796f54542192af3
parentf36ee4549eca5a6754289befdda9bf9cc93a0ee9 (diff)
signal: Add signal-map-maybe.
* sly/signal.scm (signal-map-maybe): New procedure.
-rw-r--r--sly/signal.scm13
1 files changed, 12 insertions, 1 deletions
diff --git a/sly/signal.scm b/sly/signal.scm
index 42cce40..41365a9 100644
--- a/sly/signal.scm
+++ b/sly/signal.scm
@@ -41,7 +41,9 @@
signal-set!
signal-merge
signal-zip
- signal-map signal-sample-on
+ signal-map
+ signal-map-maybe
+ signal-sample-on
signal-negate
signal-fold
signal-filter
@@ -273,6 +275,15 @@ or more SIGNALs."
(%signal-set! self (current-value)))
inputs)))
+(define (signal-map-maybe proc signal . rest)
+ "Create a new signal that applies PROC to the values stored in
+SIGNAL ... if all of them are not #f."
+ (apply signal-map
+ (lambda args
+ (and (every identity args)
+ (apply proc args)))
+ signal rest))
+
(define (signal-sample-on value-signal sample-signal)
"Create a new signal that takes on the value of VALUE-SIGNAL
whenever SAMPLE-SIGNAL receives a new value."