summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-11-30 13:51:54 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-11-30 13:51:54 -0500
commitcb6f2686e98bc964251951f33b8e597de25574a5 (patch)
treef26a3ffc91baea1098014520e6c5dd65ba103ab7
parent5133fd953ce12f03988d00f7dfe650607b95c3c1 (diff)
signal: Add signal-every and signal-since.
* sly/signal.scm (signal-every, signal-since): New procedures.
-rw-r--r--sly/signal.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/sly/signal.scm b/sly/signal.scm
index da4e1dc..20d5ba6 100644
--- a/sly/signal.scm
+++ b/sly/signal.scm
@@ -50,6 +50,7 @@
signal-tap
signal-timestamp
signal-sample
+ signal-every signal-since
signal-delay
signal-throttle
signal-generator))
@@ -347,6 +348,17 @@ every DELAY ticks of the current agenda."
"Create a new signal that delays propagation of SIGNAL by DELAY
ticks of the current agenda."
(make-boxed-signal (signal-ref signal)
+(define (signal-every step)
+ "Create a new signal that emits STEP every STEP ticks."
+ (signal-sample step (make-signal step)))
+
+(define (signal-since step signal)
+ "Create a new signal that emits the time since the last value was
+received from SIGNAL in STEP increments."
+ (signal-map (lambda (time)
+ (- (agenda-time) time))
+ (signal-sample step (signal-time signal))))
+
(lambda (self value)
(schedule
(lambda ()