Given these definitions:
(define x 1) (define (add-x y) (+ x y)) (define (dbl-x x) (+ x x)) (define (add-sum y) (let ((sum (add-x x))) (+ sum y))) (define (add-list y) (every add-x y))
For each of the following expressions, if the expression can be evaluated, write its value. If the expression cannot be evaluated, explain why not.
1
1
x
1
'x
x
y
'y
y
(x)
1
is not a procedure'(x)
(x)
('x)
x
is not a procedure(add-x 1)
2
(add-x x)
2
(add-x 'x)
x
is not a number(dbl-x 1)
2
(dbl-x x)
2
-- Here x
is global, bound to 1
(dbl-x 2)
4
-- Here 2 is bound to the local x
(add-sum 1)
3
(add-list (1 2 3))
1
is not a procedure(add-list '(1 2 3))
(2 3 4)
(add-x '(1 2 3))
(1 2 3)
is not a number(keep even? (add-list '(1 2 3)))
(2 4)