due 01/12/01
R4RS (handout). This will be very useful for completing this assignment.
Try these questions out before section. First try to figure out the answers in your head. Then try typing them into the scheme interpreter.
Given the following definitions:
(define x 10) (define y 44) (define foo '(1 2 3)) (define bar '(a b c))what are the results of the following pieces of scheme code:
What are the results of the following pieces of code?
(if #f 5 10)
(if (or #t #f) 5 10)
(if #t
(if #f 2 3)
10
)
(define x 3)
(cond ((= x 1) 44)
((= x 2) (+ 5 50))
((= x 3) (* 6 11))
(else (- 80 3))
)
(let ((x 5)
(y 10)
)
(+ x y)
)
(char-hex-letter? #\b) => #t (char-hex-letter? #\3) => #f (char-hex? #\B) => #t (char-hex? #\3) => #t
These are some sample problems that we will be discussing in section. Use the error function for handling errors.
(char-hex->number #\b) => 11
(string-hex->number "3f") => 63
(positive-only '()) => () (positive-only '(1 2 -3 4)) => (1 2 4) (positive-only '(-1 -2 -3)) => ()
Complete the following. You do not have to handle errors in input gracefully; however, if you want to you may use the error primitive function; e.g. (error "error in input"). Do not forget to turn in a print out of your source code as well as example executions of your code on test cases.
(string-hex->char "61") => #\a
For example:
(decode-hex-string "In+hex+5+%2b+5+is+%27a%27.")
=> "In hex 5 + 5 is 'a'."
(split #\space "this is a test")
=> ("this" "is" "a" "test")