Stay rational
This commit is contained in:
parent
40961e7893
commit
9009fb5ec7
|
@ -41,15 +41,15 @@
|
|||
|
||||
(spawn (versioned-field [C 0] [F 32])
|
||||
(begin/dataflow
|
||||
(F (exact->inexact (+ (* (C) 9/5) 32)) C)
|
||||
(C (exact->inexact (* (- (F) 32) 5/9)) F))
|
||||
(F (+ (* (C) 9/5) 32) C)
|
||||
(C (* (- (F) 32) 5/9) F))
|
||||
(assert (temperature 'C (C)))
|
||||
(assert (temperature 'F (F)))
|
||||
(on (message (set-temperature 'C $v)) (C v))
|
||||
(on (message (set-temperature 'F $v)) (F v)))
|
||||
|
||||
(spawn (on (asserted (temperature $unit $value))
|
||||
(printf "Temperature in ~a is ~a\n" unit value)))
|
||||
(printf "Temperature in ~a is ~a\n" unit (exact->inexact value))))
|
||||
|
||||
(spawn (on (asserted (observe (set-temperature _ _)))
|
||||
(send! (set-temperature 'C 20))
|
||||
|
|
|
@ -11,17 +11,17 @@
|
|||
(on (message (set-temperature 'C $new-temp))
|
||||
(temp new-temp))
|
||||
(on (asserted (temperature 'F $other-temp))
|
||||
(temp (exact->inexact (* (- other-temp 32) 5/9)))))
|
||||
(temp (* (- other-temp 32) 5/9))))
|
||||
|
||||
(spawn (field [temp 32])
|
||||
(assert (temperature 'F (temp)))
|
||||
(on (message (set-temperature 'F $new-temp))
|
||||
(temp new-temp))
|
||||
(on (asserted (temperature 'C $other-temp))
|
||||
(temp (exact->inexact (+ (* other-temp 9/5) 32)))))
|
||||
(temp (+ (* other-temp 9/5) 32))))
|
||||
|
||||
(spawn (on (asserted (temperature $unit $value))
|
||||
(printf "Temperature in ~a is ~a\n" unit value)))
|
||||
(printf "Temperature in ~a is ~a\n" unit (exact->inexact value))))
|
||||
|
||||
(spawn (on (asserted (observe (set-temperature _ _)))
|
||||
;; (send! (set-temperature 'C 20))
|
||||
|
|
Loading…
Reference in New Issue