PLQ #4Done on:   Tuesday, February 15th

Question 1 @ 2022-02-15 18:58

Consider this FLANG code:

{call THING ARG}

What must be true of THING?

(Choose the best answer.)

Question 2 @ 2022-02-15 19:01

We briefly discussed de Brujin Indexing in lecture. In the program below, how would we convert this to a program that uses de Brujin Indices?

{with {x 2} {with {y 7} {with {z 4} {- x y z}}}}

Question 3 @ 2022-02-15 19:02

Which of the following is true about “first-class” functions?

Question 4 @ 2022-02-15 19:05

Last week, we added functions to our language. The first shot we had at implementing the evaluation rules had:

[(Fun bound-id bound-body) expr]
[(Call (Fun bound-id bound-body) arg-expr)
[(Call something arg-expr)
(error 'eval "`call' expects a function, got: ~s" something)]

Which of the following tests will throw an error for this implementation?

Question 5 @ 2022-02-15 19:09

From the class notes, showing off some of the things that you can do with first-class functions:

(: currify : (All (A B C) (A B -> C) -> (A -> (B -> C))))
(define (currify f)
  (lambda (x) (lambda (y) (f x y))))

(: add : Number Number -> Number)
(define (add x y) (+ x y))

How would you correctly call the above currify function to add two numbers?