summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-12-06 11:15:39 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-12-06 13:20:49 -0500
commit19650ce35b164c1af1056043dbf161a1618b7c06 (patch)
tree7d3ae6500c1f42356f7fdbadf5a319e0f7751167
parentd7dbc7fc8e9c692fe9032d9f7738ffa59498034e (diff)
signal: Add signal-sample-on.
* sly/signal.scm (signal-sample-on): New procedure.
-rw-r--r--sly/signal.scm7
1 files changed, 6 insertions, 1 deletions
diff --git a/sly/signal.scm b/sly/signal.scm
index 8e2c64d..93e7716 100644
--- a/sly/signal.scm
+++ b/sly/signal.scm
@@ -39,7 +39,7 @@
signal-proc
signal-merge
signal-zip
- signal-map
+ signal-map signal-sample-on
signal-negate
signal-fold
signal-filter
@@ -239,6 +239,11 @@ or more SIGNALS."
(%signal-set! self (current-value)))
inputs)))
+(define (signal-sample-on value-signal sample-signal)
+ "Create a new signal that takes on the value of VALUE-SIGNAL
+whenever SAMPLE-SIGNAL is updated."
+ (signal-map (lambda _ (signal-ref value-signal)) sample-signal))
+
(define (signal-negate signal)
"Create a new signal whose value is the 'not' of the value of
SIGNAL."