diff options
author | David Thompson <dthompson2@worcester.edu> | 2015-03-09 08:46:43 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2015-03-09 08:46:43 -0400 |
commit | 8ac70ff3cef2963c460ce5382e37946eb0a4914e (patch) | |
tree | 1d63d0dc71997dc0e30acac168377d79cdfbd3e1 | |
parent | 7aa9d9e5dcd3dbb459343bb2372372d875cea95c (diff) |
signals: Add signal-timer.
* sly/signal.scm (signal-timer): New procedure.
* doc/api/signals.texi: Document it.
-rw-r--r-- | doc/api/signals.texi | 5 | ||||
-rw-r--r-- | sly/signal.scm | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/doc/api/signals.texi b/doc/api/signals.texi index a4e2c01..9f674e1 100644 --- a/doc/api/signals.texi +++ b/doc/api/signals.texi @@ -191,6 +191,11 @@ Create a new signal that takes on the value of @var{signal} every Create a new signal that emits @var{step} every @var{step} ticks. @end deffn +@deffn {Scheme Procedure} signal-timer [@var{step}] +Create a new signal that emits the total time elapsed since its +creation every @var{step} (1 by default) ticks. +@end deffn + @deffn {Scheme Procedure} signal-since @var{step} @var{signal} Create a new signal that emits the time since @var{signal} was updated ever @var{step} ticks. diff --git a/sly/signal.scm b/sly/signal.scm index 788bb25..83f1ea5 100644 --- a/sly/signal.scm +++ b/sly/signal.scm @@ -50,7 +50,7 @@ signal-tap signal-timestamp signal-time signal-sample - signal-every signal-since + signal-every signal-timer signal-since signal-delay signal-throttle signal-generator)) @@ -366,6 +366,11 @@ ticks." "Create a new signal that emits STEP every STEP ticks." (signal-sample step (make-signal step))) +(define* (signal-timer #:optional (step 1)) + "Create a new signal that emits the total time elapsed since its +creation every STEP ticks." + (signal-fold + 0 (signal-every step))) + (define (signal-since step signal) "Create a new signal that emits the time since SIGNAL was updated every STEP ticks." |