PLQ #6Done on:   Tuesday, November 1st

Question 1 @ 2022-11-01 18:31

What would (zero? (sub1 identity)) return:


  1. #f
  2. #t
  3. 1 which is the same as #t
  4. Type error
  5. No way to know
  6. Infinite loop

Question 2 @ 2022-11-01 18:35

Consider this implementation of a recursive binder:

[(WRec bound-id named-expr bound-body)
(eval bound-body
      (Some-Kind-of-Extend bound-id (eval named-expr env) env))]

What’s wrong with it?


  1. It is perfectly fine.
  2. It is fine, except for WRec which should be Rec.
  3. Impossible to tell without knowing how Some-Kind-of-Extend is implemented.
  4. It will lead to a type error: undefined value
  5. The named-expr is evaluated too early and with the previous environment.
  6. It can create an infinite loop.

Question 3 @ 2022-11-01 18:38

Which of the following is true about Y?


  1. Y(f) = Y(Y(f))
  2. Y(f) = Y(f(f))
  3. Y(f) = Y(f(Y))
  4. Y(f) = f(Y(f))
  5. Y(f) = f(f(Y))
  6. Y(f) = Y(f) (recursively, forever)

Question 4 @ 2022-11-01 18:41

Based on the following Schlac code:

#lang pl schlac
...
(define #f (lambda (a b) b))

(test (->nat #f) => ___)

What should go in the blank for the test to pass?


A. 0 B. 1 C. ’0 D. ’1 E. Impossible to tell.

Question 5 @ 2022-11-01 18:45

(Warning: hard question, will be worth a third of the points.)

Say that you have the following function declaration, unknown body, and one test shows what it does in a specific case:

#lang schlac
;; foo : (Listof A) -> (Listof A)
(define foo
  (lambda (l) ...?...))
;; single test that is known to pass
(test (->listof ->nat (foo (cons 1 (cons 2 null))))
      => '(2 1))

can you tell what will be the result of this:

(->listof ->bool (foo (cons #t (cons #f null))))

(Hint: the type is very important!)


  1. ’(#f #t)
  2. ’(#t #f)
  3. Impossible to tell.
  4. Type error.

Question 6 @ 2022-11-01 18:52

(Warning: hard question, will be worth a third of the points.)

Say that you have the following function declaration, unknown body, and one test shows what it does in a specific case:

#lang pl
(: foo : (Listof A) -> (Listof A))
(define (foo l)
  ...?...)
;; single test that is known to pass
(test (foo '(1 2 3))
      => '(3 2 1))

can you tell what will be the result of this:

(foo '("foo" "bar" "baz"))

(Hint: the type is very important!)


  1. ’(“foo” “baz” “bar”)
  2. ’(“baz” “bar” “foo”)
  3. Impossible to tell.
  4. Type error.

Question 7 @ 2022-11-01 19:02

(Warning: hard question, will be worth a third of the points.)

Say that you have the following function declaration, unknown body, and one test shows what it does in a specific case:

#lang schlac
;; foo : (Listof A) -> (Listof A)
(define foo
  (lambda (l) ...?...))
;; single test that is known to pass
(test (->listof ->nat (foo (cons 1 (cons 2 null))))
      => '(2 1))

can you tell what will be the result of this:

(->listof ->bool (foo (cons #t (cons #f (cons #t null)))))

(Hint: the type is very important!)


  1. ’(#t #f #t)
  2. ’(#t #f)
  3. Impossible to tell.
  4. Type error.