diff options
author | David Thompson <dthompson@member.fsf.org> | 2013-12-02 09:50:04 -0500 |
---|---|---|
committer | David Thompson <dthompson@member.fsf.org> | 2013-12-02 09:50:04 -0500 |
commit | 603f428ffe3f8882ed39b9af89dcaa9b3e3b5ba4 (patch) | |
tree | d4499be484ac43484a294b811e35c6f613213be7 /2d | |
parent | 4582ceb5428ef6aee881df57bbdfaea7f2ae6730 (diff) |
Define signal-constant in terms of signal-lift.
* 2d/signals.scm (signal-constant): Rewrite.
Diffstat (limited to '2d')
-rw-r--r-- | 2d/signals.scm | 12 |
1 files changed, 5 insertions, 7 deletions
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 |