Spec and Impl of Conditionals
(value-of 𝑒𝑥𝑝₁ ρ) = 𝑣𝑎𝑙₁
---------------------------------------------
(value-of (if-exp 𝑒𝑥𝑝₁ 𝑒𝑥𝑝₂ 𝑒𝑥𝑝₃) ρ)
= --- (value-of 𝑒𝑥𝑝₂ ρ) if (expval->bool 𝑣𝑎𝑙₁) = #t
|
--- (value-of 𝑒𝑥𝑝₃ ρ) if (expval->bool 𝑣𝑎𝑙₁) = #f
(define value-of
(lambda (exp env)
(cases expression exp
...
(if-exp (exp1 exp2 exp3)
(let ((val1 (value-of exp1 env)))
(if (expval->bool val1)
(value-of exp2 env)
(value-of exp3 env)))))))