blggr's Journal
[Most Recent Entries]
[Calendar View]
[Friends]
Below are the 2 most recent journal entries recorded in
blggr's LiveJournal:
Thursday, December 28th, 2006 | 10:35 pm |
1.2 1.3 1.5 #| the output is from MIT's Scheme compiler |#
; 1.2
1 ]=> (/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5))))) (* 3 (- 6 3) (- 3 7)))
;Value: -37/90 1 ]=>
; 1.3 1 ]=> (define (sum-of-squares a b) (+ (* a a) (* b b))) ;Value: sum-of-squares
1 ]=> (define (sum-of-larger-nums a b c) (cond ( (and (<= a b) (<= a c)) (sum-of-squares b c)) ( (and (<= a b) (>= a c)) (sum-of-squares a b)) ( (and (<= a c) (>= a b)) (sum-of-squares a c)) (else (if (< b c) (sum-of-squares a c) (sum-of-squares a b)))))
;Value: sum-of-larger-nums 1 ]=>
; 1.5
#| normal-order evaluation will postpone evaluating the value of (p) until the first condition of if-clause fails. Since x==0, (p) will never be evaluated, and the value of 0 will be returned by the invocation of test.
applicative-order evaluation will first evaluate argument values. Therefore it will trip on (p), which is undefined (???). In other words, it will never reach the stage of performing test on the operands |#
Current Music:
structure and interpretation of computer programs | 10:08 pm |
structure and interpretation of computer programs -- Abelson, Sussman & Sussman I'll try to post my solutions to exercises as i progress thru the book.
any corrections or suggestions are welcome, since many of them will likely be suboptimal
so for what they're worth... |
|