diff options
author | David Thompson <dthompson2@worcester.edu> | 2014-07-22 21:33:17 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2014-07-22 21:33:17 -0400 |
commit | e631beee10d31840b69c96f32585d54e3a467999 (patch) | |
tree | b13a94f8724f977001f1041d3688c6c6090445f8 | |
parent | 688a466cbfda1e7aeb9e8dfc50e5d40626741af8 (diff) |
Add optional start and step parameters to signal-count.
* sly/signal.scm (signal-count): Add start and step parameters.
-rw-r--r-- | sly/signal.scm | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sly/signal.scm b/sly/signal.scm index aab18b8..3988812 100644 --- a/sly/signal.scm +++ b/sly/signal.scm @@ -276,10 +276,11 @@ signal PRED is true, or the value of the signal OFF otherwise." value of SIGNAL." (signal-map (lambda (value) constant) signal)) -(define (signal-count signal) - "Create a new signal that increments a counter every time a new -value from SIGNAL is received." - (signal-fold + 0 (signal-constant 1 signal))) +(define* (signal-count signal #:optional (start 0) (step 1)) + "Create a new signal that increments a counter by STEP every time a +new value from SIGNAL is received, with an initial value of START. By +default, START is 0 and STEP is 1." + (signal-fold + start (signal-constant step signal))) (define (signal-tap proc signal) "Create a new signal that applies PROC when a new value is received |