Ex. 1.1
Welcome to DrScheme, version 372 [3m].
Language: Advanced Student.
> 10
10
> (+ 5 3 4)
12
> (- 9 1)
8
> (/ 6 2)
3
> (+ (* 2 4) (- 4 6))
6
> (define a 3)
> (define b (+ a 1))
> (+ a b (* a b))
19
> (= a b)
false
> (if (and (> b a) (< b (* a b)))
b
a)
4
> (cond ((= a 4) 6)
((= b 4) (+ 6 7 a))
(else 25))
16
> (+ 2 (if (> b a) b a))
6
> (* (cond ((> a b) a)
((< a b) b)
(else -1))
(+ a 1))
16
>
Ex. 1.2
Welcome to DrScheme, version 372 [3m].
Language: Advanced Student.
> (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5)))))
14.8
> (* 3 (- 6 2) (- 2 7))
-60
> (/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5)))))
(* 3 (- 6 2) (- 2 7)))
-0.246
Ex. 1.3
(define (square x) (* x x))
(define (sos x y) (+ (square x) (square y)))
(define (big3-sos x y z)
(cond ((and (< x y) (< y z)) (sos y z))
((and (< z x) (< z y)) (sos x y))
(else (sos x z))))
Ex. 1.4
If b is less than zero, the - procedure is called to subtract a from
-b. If b is greater than zero, the + procedure is called to simply add
a and b.
Ex. 1.5
I would think applicative order would return zero since it's going to
evaluate x first. Normal order, I'm not sure what it'll do. Trying it
with drscheme, it just keeps running forever without any end. Consumes
about 50% CPU, and eventually kicks the fan on the laptop CPU. When I
stop the process, it always stoped on (p) in the define.
--
Mark Schoonover, CMDBA
http://www.linkedin.com/in/markschoonover
http://marksitblog.blogspot.com
[EMAIL PROTECTED]
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg