From 603f428ffe3f8882ed39b9af89dcaa9b3e3b5ba4 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 2 Dec 2013 09:50:04 -0500 Subject: Define signal-constant in terms of signal-lift. * 2d/signals.scm (signal-constant): Rewrite. --- 2d/signals.scm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to '2d') diff --git a/2d/signals.scm b/2d/signals.scm index 0d7c75b..7661434 100644 --- a/2d/signals.scm +++ b/2d/signals.scm @@ -140,13 +140,6 @@ will be set if it passes through the filter." ;;; Primitive signals ;;; -(define (signal-constant constant) - "Create a new signal with a value CONSTANT that cannot be changed." - (make-signal - #:transformer (lambda (value prev from) - constant) - #:init constant)) - ;; TODO: Write a macro for generating lifts (define (signal-lift transformer signal) "Create a new signal that lifts the procedure TRANSFORMER of arity 1 @@ -220,6 +213,11 @@ of SIGNAL changes." (1+ prev)) #:connectors (list signal))) +(define (signal-constant constant signal) + "Create a new signal that emits the value CONSTANT whenever a new +value is received from SIGNAL." + (signal-lift (lambda (value) constant) signal)) + (define (signal-if predicate consequent alternate) "Create a new signal that emits the value of the signal CONSEQUENT when the value of the signal PREDICATE is true and the value of the -- cgit v1.2.3