SICP - Solution: Exercise 1.4

SICP - Solution: Exercise 1.4

September 26, 2018

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:

(define (a-plus-abs-b a b)
  ((if (> b 0) + -) a b))

Solution

If $b$ is strictly a positive number, the function returns $a+b$, else it returns $a-b$.

In other words, this function compute ${a+\left|b\right|.}$