Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 594 Bytes

4.md

File metadata and controls

18 lines (12 loc) · 594 Bytes

Exercise 1.4

Observe that our model of evaluation allows for combinations whose operators are compound expression. Use this observation to describe the behaviour of the following procedures:

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

if our argument b for the procedure a-plus-abs-b is bigger than 0, we will add a and b

$f(x) = a + b$

If our argument b for procedure a-plus-abs-b is less than 0, we will minus a and b

$f(x) = a - b$ where b is negative

Effectively, this means that a always adds to the absolute value of b

$f(x) = a + \lvert b \rvert$