PLQ #9Done on:   Tuesday, March 29th

Question 1 @ 2022-03-29 18:35

As a reminder from last week, I was concerned that some of you do not have a complete understanding of what a closure is. Choose the TWO statements below that are correct.


Question 2 @ 2022-03-29 18:55

In lecture last week, we started to build our TOY compiler. Which statement is FALSE about the discussion about refactoring our language evaluator into a compiler?

(define (compile expr)
  (cases expr
    [(Num n)  (lambda ([env : ENV]) (RktV n))]
    [(Id name) (lambda ([env : ENV]) (lookup name env))]
    ...))

Question 3 @ 2022-03-29 19:00

If this is our code in the definitions window:

#lang pl lazy
(define l (append (list #f 2 (+ 3 "a")) l))

and then we enter the following on the REPL:

(or (first l) (fifth l))

what would we get?


Question 4 @ 2022-03-29 19:26

If the following code is run with lazy evaluation, which functions will get called?

(second (list (/ 2 0) (add1 2) (+ 1 3)))

(Note the multiple choice)


Question 5 @ 2022-03-29 19:29

If the following code is run with eager evaluation, which functions will get called?

(second (list (/ 2 0) (add1 2) (+ 1 3)))

(Note the multiple choice)