Exercise1-3 <---> Exercise1-5
Exercise 1.4.
Observe that our model of evaluation allows for combinations whose operators are compound expressions. Use this observation to describe the behavior of the following procedure:
Ru: Заметим, что наша модель вычислений разрешает существование комбинаций, операторы которых — составные выражения. С помощью этого наблюдения опишите, как работает следующая процедура:
(define (a-plus-abs-b a b)
((if (> b 0) + -) a b))
Solution:
Expression (> b 0) is evaluated firstly, if result is true we will apply '+' function to a and b arguments, otherwise we'll apply '-' (minus) function to a and b.
Ru: В начале вычисляется выражение (> b 0), затем, если результат вычисления true - мы применяем функцию '+' к аргументам a b, в противном случаем мы применяем функцию '-' (минус) к ним же.
Exercise1-3 <---> Exercise1-5