diff options
author | David Thompson <dthompson@member.fsf.org> | 2013-12-02 09:58:53 -0500 |
---|---|---|
committer | David Thompson <dthompson@member.fsf.org> | 2013-12-02 09:58:53 -0500 |
commit | bb3b1daffce323d8aa17eb2c078698faaaab7835 (patch) | |
tree | 7fab51ecc371dd80eb73818424cf013316ba29db | |
parent | 603f428ffe3f8882ed39b9af89dcaa9b3e3b5ba4 (diff) |
Define signal-count in terms of signal-fold.
* 2d/signals.scm (signal-count): Rewrite.
-rw-r--r-- | 2d/signals.scm | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/2d/signals.scm b/2d/signals.scm index 7661434..502aada 100644 --- a/2d/signals.scm +++ b/2d/signals.scm @@ -208,10 +208,9 @@ values of SIGNAL using PROC." (define (signal-count signal) "Create a new signal that increments a counter every time the value of SIGNAL changes." - (make-signal - #:transformer (lambda (value prev from) - (1+ prev)) - #:connectors (list signal))) + ;; Initial value is -1 to compensate for the inital signal update + ;; when connecting. + (signal-fold (lambda (new old) (1+ old)) -1 signal)) (define (signal-constant constant signal) "Create a new signal that emits the value CONSTANT whenever a new |