
REGISTER MACHINES - 1

    It is the error in this statement:

        (assign lst (op car) (cdr (reg lst)))


                        Answer: can't have nested operations


REGISTER MACHINES - 2

    The contract a stack implements.


                        Answer: Last In, First Out


REGISTER MACHINES - 3

    The missing line for the register machine below,
    designed to test for primality:

        (define-machine prime?
          (registers n div stop val temp)
          (controller
            (assign val (const #f))
            (test (op =) (reg n) (const 2))
            (branch (label is-prime))
            (assign temp (op remainder) (reg n) (const 2))
            (test (op zero?) (reg temp))
            (branch (label prime-done))
            (assign stop (op sqrt) (reg n))
            (assign div (const 3))
          loop
            (test (op >) (reg div) (reg stop))
            (branch (label is-prime))
            (assign temp (op remainder) (reg n) (reg div))
            (test (op zero?) (reg temp))
            (branch (label prime-done))
            ****
            (goto (label loop))
          is-prime
            (assign val (const #t))
          prime-done))


            Answer: (assign div (op +) (reg div) (const 2))


REGISTER MACHINES - 4

    The function performed on registers x and y by the
    following register machine.

        (define-machine mystery
          (register x y aux val continue)
          (controller
            (assign continue (label mystery-done))
          mystery-loop
            (test (op null?) (reg x))
            (branch (label base-case))
            (assign aux (op car) (reg x))
            (save continue)
            (save aux)
            (assign x (op cdr) (reg x))
            (assign continue (label after-loop))
            (goto (label mystery-loop))
          after-loop
            (restore x)              ;; car is now in x 
            (restore continue)
            (assign val (op cons) (reg x) (reg val))
            (goto (reg continue))
          base-case
            (assign val (reg y))
            (goto (reg continue))
          mystery-done))

                        Answer: (append x y)



COMPILERS - 1

    Either of the two biggest advantages of a compiler over
    an interpreter.


                        Answer: shorter code, object code


COMPILERS - 2

    The Scheme fragment that created the following code:

    (assign proc (op lookup-variable-value) 
                                (const lst) (reg env))
    (assign val (op lookup-variable-value) 
                                (const null?) (reg env))
    (assign argl (op list) (reg val))
    (test (op primitive-procedure?) (reg proc))
    (branch (label prim-branch11))
  compound-branch12
    (assign continue (label after-call71))
    (assign val (op compiled-procedure-entry) (reg proc))
    (goto (reg val))
  prim-branch11
    (assign val (op apply-primitive-procedure) 
                                (reg proc) (reg argl))
  after-call71


                        Answer: (lst null?)

          ----------------------------------------

COMPILERS - 3

    When interpreted code and compiled code are compared,
    these are the instructions eliminated most often.


                        Answer: save and restore

          ----------------------------------------

COMPILERS - 4

    The missing line in the compiled code below, which is
    the result of evaluating (f (+ 1 x) y):


   (assign proc (op lookup-variable-value) (const f) (reg env))
   (save proc)
   (save env)
   (assign proc (op lookup-variable-value) (const +) (reg env))
   (assign val (op lookup-variable-value) (const x) (reg env))
   (assign argl (op list) (reg val))
   (assign val (const 1))
   (assign argl (op cons) (reg val) (reg argl))
   <apply-dispatch>
 after-call21
   ***********                       ;;; missing line here
   (restore env)
   (assign val (op lookup-variable-value) (const y) (reg env))
   (assign argl (op cons) (reg val) (reg argl))
   (restore proc)
   <apply-dispatch>


        Answer: (assign argl (op list) (reg val))


________________________________________


MISCELLANEOUS - 1

    Prof. Duane Boning's office room (not phone) number.


                        Answer: 39-567

          ----------------------------------------

MISCELLANEOUS - 2

    This is a publicly and freely available software
    implementation of RSA encryption capability.


                        Answer: PGP

          ----------------------------------------

MISCELLANEOUS - 3

    It is the problem with the following fragment of code:

        (define vector cons)
        (define get-x car)
        (define get-y cdr)
        (define v1 (vector 2 3))
        (define (magnitude vec)
          (let ((cars (* (car vec) (car vec)))
                (cdrs (* (cdr vec) (cdr vec))))
            (sqrt (+ cars cdrs))))
                
                        Answer: Abstraction violation!!

          ----------------------------------------

MISCELLANEOUS - 4

    He developed LISP.


                        Answer: John McCarthy

MC-EVAL - 3

    The number of times the eval procedure is invoked when
    the following expression is entered into the evaluator:

        ((lambda (x) (* x 2)) 3)

                        Answer: seven [let f be the lambda
                         expression]; 1--(f 3), 2--f, 3--3,
                         4--(* x 2), 5--*, 6--x, 7--2

          ----------------------------------------

MC-EVAL - 4

    The one and only line needed to modify the evaluator to
    handle define statements of the form:

        (<variable> := <binding>)

    Answer: ((eq? (cadr exp)) ':=)
             (eval-define (list (car exp) (caddr exp)) env))



POTPOURRI - 1

    Professor Boning's major(s) when he was an undergraduate.


                        Answer: 6-1 and 6-3

POTPOURRI - 2

  What answers does this give?

        (let  ((x (amb -3 -2 -1 0 1 2 3)))
          (require (= (* x x) 4))
          x)

      Answers: -2 and 2



POTPOURRI - 3

  What questions should you ask about a new language?


      Answer: 
        What are the primitives?
        What are the means of combination?
        What are the means for abstraction?


POTPOURRI - 4

    The person(s) to whom there is a seat dedicated in the
    10-250 lecture hall.

(a) Gerry Sussman
(b) Albert Meyer
(c) Hal Abelson
(d) Ben and Alyssa P. (Hacker) Bitdiddle
(e) Louis Reasoner

                        Answer: D
