PLQ #3Done on:   Tuesday, October 11th

Question 1 @ 2022-10-11 18:46

Which of the following are true about different treatments of functions in programming languages?


FOV. First order: functions can be used as values FOS. First order: function values can be created in any scope

HOV. Higher order: functions can be used as values HOS. Higher order: function values can be created in any scope

FCV. First class: functions can be used as values FCS. First class: function values can be created in any scope

Question 2 @ 2022-10-11 18:50

What would be the result of running this expression using our Flang language implementation (the one with substitutions)?

{with {+ *} {+ 1 2}}

  1. Compilation error
  2. 2
  3. 3
  4. Unbound + error
  5. Unbound * error
  6. bad with syntax in

Question 3 @ 2022-10-11 18:57

Given the following code and one sample test:

(define (fix1 f x)
  (lambda (y) (f x y)))

(test ((fix1 mul 10) 5) => 50)

Which of the following type declarations is best for fix1?


  1. (: fix1 : (All (A B) (A A -> B) -> A -> B))
  2. (: fix1 : (All (A B) (A A -> B) A -> (A -> B)))
  3. (: fix1 : (All (A B C) (A B -> C) A -> (B -> C)))
  4. (: fix1 : (All (A B C) (A B -> C) -> (A -> (B -> C))))
  5. (: fix1 : (All (A B C) (A B -> C) -> A -> (B -> C)))
  6. (: fix1 : (All (A B C) (A B -> C) (A -> B) -> C))

Question 4 @ 2022-10-11 19:05

Reminder: all the way from AE to FLANG, we implement arithmetic operations like + with

[(Add l r) (+ (eval l) (eval r))]

The question is whether our language is evaluating these expressions left-to-right or right-to-left?


  1. LtR
  2. RtL
  3. Either LtR or RtL; it’s nondeterministic so we cannot tell which one.
  4. Whatever it is that Racket does.
  5. The question is nonsensical: our languages are unrelated to Racket.
  6. No way to answer, since it depends on how the CPU optimizes the order.

Question 5 @ 2022-10-11 19:15

Are the following FLANG expressions equivalent?

A. {+ E1 E2} B. {with {x E1} {with {y E2} {+ x y}}} C. {with {y E2} {with {x E1} {+ x y}}}

Choose all of the correct statements.


AB. A is equivalent to B AC. A is equivalent to C BC. B is equivalent to C

W1. All would be equivalent if this is limited to WAE W2. All would be equivalent if this is limited to WAE without division