From e631beee10d31840b69c96f32585d54e3a467999 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 22 Jul 2014 21:33:17 -0400 Subject: Add optional start and step parameters to signal-count. * sly/signal.scm (signal-count): Add start and step parameters. --- sly/signal.scm | 9 +++++---- 1 file 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 -- cgit v1.2.3