Question 1 @ 20210309 19:09
What is the output of this function in our BRANG language?
{with {x 2}
{bind* {{x 6} {y x}}
{bind {{x y} {y x}}
{ x y}}}}
 6
 4
 4
 0
 Runtime error
Question 2 @ 20210309 19:14
What must be true in order for
E == (lambda (x) (E x))
 E is a function
 E evaluates to a function
 E must have the same arity as x
 E is unary
 A and C
 B and D
 All of the above
Question 3 @ 20210309 19:19
Below is the truth table of XOR:
X Y Result
T T F
F T T
T F T
F F F
Which one of the following is a correct implementation?

(define xor (lambda (a b) (a (b a b) b)))

(define xor (lambda (a b) (a (b #f a) b)))

(define xor (lambda (a b) (a (b a #f) b)))

(define xor (lambda (a b) (a (b #f a) a)))

(define xor (lambda (a b) (a (b a b) a)))
 None of the above
Question 4 @ 20210309 19:24
Given the following implementations of car, cdr, and cons in Schlac:
(define #t (lambda (x y) x))
(define #f (lambda (x y) y))
(define car (lambda (p) (p #t)))
(define cdr (lambda (p) (p #f)))
(define cons (lambda (x y) (lambda (s) (s x y))))
What happens when we run this test?
(define 3rd (lambda (l) (car (cdr (cdr l)))))
(define lon (cons 2 (cons 1 0)))
(test (>nat (3rd lon)) => 0)
 The test passes, since the 3rd element in
lon
is 0
 The test fails, because the program throws an error trying to
call
car
on the last element of lon
 The test fails, because we get a type mismatch error from not
properly specifying types
 The test probably fails, because
(3rd lon)
produces some
nonsensical result which is unlikely the Church Numeral encoding of
0
 The test fails, because our definitions of
car
, cdr
, and
cons
are not well formed