PLQ #7Done on:   Tuesday, March 8th

Question 1 @ 2022-03-08 18:56

In Schlac, using our definitions and encoded values, what does the following code block evaluate to?

(if (lambda (x y) y)
  ((lambda (x) (x x)) (lambda (x) (x x)))
  (* 3 5))

Question 2 @ 2022-03-08 18:59

Which of the following is the combinator version of the Church encoding for the cdr function?


Question 3 @ 2022-03-08 19:01

In class, we briefly discussed the difference the functionality of bind and and bind* from HW#8. What would the following code snippet evaluate to?

{bind {{x 1}}
  {bind* {{x 2}
          {y x}}
    {bind {{x 3}}
      y}}}

Question 4 @ 2022-03-08 19:04

How can the following Racket code be fixed so that we actually get the factorial of 4?

(let ([fact (lambda (n)
              (if (= n 0)
                1
                (* n (fact (- n 1)))))])
  (fact 4))

Question 5 @ 2022-03-08 19:07

In class last week, we briefly discussed letrec and its differences from let* and let. Which of the following answers is true about our extended FLANG language that has a proper rec recursive binder with no tricks and no Y combinator complexity?