summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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."