From 5571463e79247d6cb338a015e5bbf94d4bafde44 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 10 Feb 2016 21:59:10 -0500 Subject: signal: Add signal-map-maybe. * sly/signal.scm (signal-map-maybe): New procedure. --- sly/signal.scm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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." -- cgit v1.2.3