diff options
-rw-r--r-- | 2d/signals.scm | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/2d/signals.scm b/2d/signals.scm index 400f61e..0d7c75b 100644 --- a/2d/signals.scm +++ b/2d/signals.scm @@ -45,6 +45,7 @@ signal-lift4 signal-merge signal-combine + signal-fold signal-count signal-if signal-and @@ -202,6 +203,15 @@ list." (map signal-ref signals)) #:connectors signals)) +(define (signal-fold proc init signal) + "Create a new signal that accumulates the current and previous +values of SIGNAL using PROC." + (make-signal + #:init init + #:transformer (lambda (value prev from) + (proc value prev)) + #:connectors (list signal))) + (define (signal-count signal) "Create a new signal that increments a counter every time the value of SIGNAL changes." |