Stay rational

This commit is contained in:
Tony Garnock-Jones 2017-08-10 17:40:15 -04:00
parent 40961e7893
commit 9009fb5ec7
2 changed files with 6 additions and 6 deletions

View File

@ -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))

View File

@ -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))