Consider the following definition:
(define foo
(lambda (x y)
(if (= x y)
0
(+ x (foo (+ x 1) y)))))
What is the test expression? (write the actual expression, not its value)
I would think it is just (if (= x y) but the MIT 6.001 On Line Tutor is not accepting that answer.
The test would be:
(= x y)
That's the expression that actually returns a boolean value, and the behaviour of the if
conditional expression depends on it - if it's #t
(or in general: any non-false value) the consequent part will be executed: 0
. Only if it's #f
the alternative part will be executed: (+ x (foo (+ x 1) y))
.