All pastes #187271 Raw Edit

Anonymous

public text v1 · immutable
#187271 ·published 2006-09-30 23:28 UTC
rendered paste body
8.4.1
3. Evaluate the following expression step by step:
      (cond
        [(= 2 0) false]
        [(> 2 1)(symbol=? 'a 'a)]
        [else (= (/ 1 2) 9)])
 
  ==> (cond
        [false false]
        [(> 2 1)(symbol=? 'a 'a)]
        [else (= (/ 1 2) 9)])

  ==> (cond
        [true]
        [(> 2 1)(symbol=? 'a 'a)]
        [else (= (/ 1 2) 9)])

  ==> (cond
        [true]
        [true (symbol=? 'a 'a)]
        [else (= (/ 1 2) 9)])

  ==> (cond
        [true]
        [true true]
        [else (= (/ 1 2) 9)])

  ==> (cond
        [true]
        [true]
        [else (= (/ 1 2) 9)])

  ==> All definitions successfully evaluated.

8.4.2
3. Evaluate the following expressions step by step:

   ;; f: number number -> number
   (define (f x y) (+ (* 3 x)(* y y)))

      (f (f 1 (* 2 3)) 19)

  ==> (f (f 1 6) 19)
  ==> (f (+ (* 3 1)(* 6 6)) 19)
  ==> (f (+ 3 (* 6 6)) 19)
  ==> (f (+ 3 36) 19)
  ==> (f 39 19)
  ==> (+ (* 3 39)(* 19 19))
  ==> (+ 117 361)
  ==> 478

8.8.3
2. Evaluate the following expressions step by step:

   (define-struct ball (x y speed-x speed-y))

      (ball-speed-y (make-ball (+ 1 2)(+ 3 3) 2 3))
  ==> (ball-speed-y (make-ball 3 (+ 3 3) 2 3))
  ==> (ball-speed-y (make-ball 3 6 2 3))
  ==> 3