temperature conversion

Every now and then it is useful to convert temperatures, and guess I have settled on the name "the Feynman knowledge engine" for this project, and so the need for some simple conversions. I could give the code, but it doesn't illuminate too much. Temperature conversion is simple enough, and has very well known equations.

So, just some examples (noting that F is Fahrenheit, C is Celcius, and K is Kelvin):
sa: F |C: 0>
|F: 32.00>

sa: C |K: 0>
|C: -273.15>

sa: C |F: 100>
|C: 37.78>

sa: K |C: 0>
|K: 273.15>

sa: F |C: 40>
|F: 104.00>
And using linearity of these operators, and the range() function, we can build a quick temperature conversion table: eg, for F and C:
-- create a list of Celcius temperatures:
sa: range(|C: 0>,|C: 100>,|10>)
|C: 0> + |C: 10> + |C: 20> + |C: 30> + |C: 40> + |C: 50> + |C: 60> + |C: 70> + |C: 80> + |C: 90> + |C: 100>

-- the equivalent in Fahrenheit:
sa: F range(|C: 0>,|C: 100>,|10>)
|F: 32.00> + |F: 50.00> + |F: 68.00> + |F: 86.00> + |F: 104.00> + |F: 122.00> + |F: 140.00> + |F: 158.00> + |F: 176.00> + |F: 194.00> + |F: 212.00>

-- create a list of Fahrenheit temperatures:
sa: range(|F: 0>,|F: 100>,|10>)
|F: 0> + |F: 10> + |F: 20> + |F: 30> + |F: 40> + |F: 50> + |F: 60> + |F: 70> + |F: 80> + |F: 90> + |F: 100>

-- the equivalent in Celcius:
sa: C range(|F: 0>,|F: 100>,|10>)
|C: -17.78> + |C: -12.22> + |C: -6.67> + |C: -1.11> + |C: 4.44> + |C: 10.00> + |C: 15.56> + |C: 21.11> + |C: 26.67> + |C: 32.22> + |C: 37.78>
And I guess that is about it. All very simple. But nice to have.

Update: now with the magic of tables:
-- define a couple of operators:
sa: F |*> #=> F |_self>
sa: K |*> #=> K |_self>

-- show the table:
sa: table[C,F,K] range(|C: 0>,|C: 100>,|10>)
+-----+--------+--------+
| C   | F      | K      |
+-----+--------+--------+
| 0   | 32.00  | 273.15 |
| 10  | 50.00  | 283.15 |
| 20  | 68.00  | 293.15 |
| 30  | 86.00  | 303.15 |
| 40  | 104.00 | 313.15 |
| 50  | 122.00 | 323.15 |
| 60  | 140.00 | 333.15 |
| 70  | 158.00 | 343.15 |
| 80  | 176.00 | 353.15 |
| 90  | 194.00 | 363.15 |
| 100 | 212.00 | 373.15 |
+-----+--------+--------+



Home
previous: walking our grid
next: context recall vs x apply op

updated: 19/12/2016
by Garry Morrison
email: garry -at- semantic-db.org