summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-02-10 21:58:41 -0500
committerDavid Thompson <dthompson2@worcester.edu>2016-02-10 22:01:38 -0500
commitf36ee4549eca5a6754289befdda9bf9cc93a0ee9 (patch)
tree800f3bfbf4583ea875aae9803f586dfff095edaa
parentc42111ad39d4b1ebef3d02d207e1f6bfa0d4022d (diff)
signal: Add signal-if.
* sly/signal.scm (signal-if): New syntax.
-rw-r--r--sly/signal.scm4
1 files changed, 4 insertions, 0 deletions
diff --git a/sly/signal.scm b/sly/signal.scm
index 5bd9a29..42cce40 100644
--- a/sly/signal.scm
+++ b/sly/signal.scm
@@ -48,6 +48,7 @@
signal-drop
signal-drop-repeats
signal-switch
+ signal-if
signal-constant
signal-count
signal-tap
@@ -341,6 +342,9 @@ signal PRED is true, or the value of the signal OFF otherwise."
(%signal-set! self (current-value)))
(list predicate)))
+(define-syntax-rule (signal-if predicate consequent alternate)
+ (signal-map (lambda (true?) (if true? consequent alternate)) predicate))
+
(define (signal-constant constant signal)
"Create a new signal whose value is always CONSTANT no matter the
value of SIGNAL."