From bb3b1daffce323d8aa17eb2c078698faaaab7835 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 2 Dec 2013 09:58:53 -0500 Subject: Define signal-count in terms of signal-fold. * 2d/signals.scm (signal-count): Rewrite. --- 2d/signals.scm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to '2d') 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 -- cgit v1.2.3