Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 ]=> ; Exercise 1.9. Each of the following two procedures defines a method for adding two positive integers in terms of the procedures inc, which increments its argument by 1, and dec, which decrements its argument by 1.
- (define (inc x)
- (+ x 1))
- ;Value: inc
- 1 ]=> (define (dec x)
- (- x 1))
- ;Value: dec
- 1 ]=> (define (+ a b)
- (display a)(newline)
- (if (= a 0)
- b
- (inc (+ (dec a) b))))
- ;Value: +
- 1 ]=> (+ 4 5)4
- 3
- 2
- 1
- 0
- 5
- 4
- 3
- 2
- 1
- 0
- 1
- 0
- 1
- 0
- 1
- 0
- 1
- 0
- 1
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement