Skip to content

Instantly share code, notes, and snippets.

@cslarsen
Created September 8, 2012 14:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cslarsen/3675478 to your computer and use it in GitHub Desktop.
R7RS version of Celsius-Fahrenheit table
#|
| Celsius-Fahrenheit temperature table
|
| Taken from
| http://programmingpraxis.com/2012/09/07/the-first-two-programs/2/
|
| Ported to current R7RS scheme by Christian Stigen Larsen
| Public Domain, 2012
|
| Works in Mickey Scheme
|
| Since R7RS is under development, you have to make a few modifications to
| make it run under R7RS draft 6, i.e., in Chibi Scheme:
|
| - Import (scheme inexact) instead of (scheme math)
| - Call inexact->exact instead of exact
|#
(import (scheme write)
(scheme base)
(scheme math))
(define (temp-table)
(do ((f 0 (+ f 20))) ((< 300 f))
(display f)
(display #\tab)
(display (exact (round (* (- f 32) 5/9))))
(newline)))
(temp-table)
@cslarsen
Copy link
Author

cslarsen commented Sep 8, 2012

The output is:

$ ./mickey test/celsius-fahrenheit.scm
0 -18
20 -7
40 4
60 16
80 27
100 38
120 49
140 60
160 71
180 82
200 93
220 104
240 116
260 127
280 138
300 149

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment