Here is some additional information on Scheme
---------------------------------------------
Logical predicates: and, or, not
Predicates for numbers: = , <>, <, <=, >, >=
integer?, float?, zero?, even?
Equality: eq? [same object pointers]
equal? [look the same when printed]
Dotted pairs: Actual form rather than lists!
Example: (cons 3 4) -> (3 . 4)
(car (3 . 4)) -> 3
(cdr (3 . 4)) -> 4
(list exp1 exp2 ... expn) =
(cons exp1 (cons exp2 ... (cons expn nil) ... ))
Thus, lists are like dotted pairs with nil as last cdr.
Predicates: pair?, atom? [not a pair]
Also, string?, string=? and many character predicates
such as char?, char=?, char, etc.
Built-in methods: (append L1 L2), (reverse L), graphics
Scope:
(define (factorial n)
(define factorial-aux count result)
(cond ((zero? count) result)
(#t (factorial-aux (-1+ count) (* count result)))))
(factorial-aux (n 1)))
; factorial-aux is not known outside factorial
; io.s
; Here is how to preserve your Scheme output in a file.
; I used a:/scode/shw.out as an example to show that
; you may put it in any directory or disk and you use
; the "forward" slash.
(define output (open-output-file "a:/scode/shw.out"))
(write 'Test output) (newline output)
(write 'Test) (newline)
(write (car '(a b c)) output) (newline output)
(write (car '(a b c))) (newline)
(close-output-port output)