SICP Exercise 2.39 reverse as fold
Exercise 2.39. Complete the following definitions of reverse (exercise 2.18) in terms of fold-right and fold-leftfrom exercise 2.38:
(define (reverse sequence)
(fold-right (lambda (x y) <??>) nil sequence))
(define (reverse sequence)
(fold-left (lambda (x y) <??>) nil sequence))
SOLUTION
The code and tests are here.
(define (reverse sequence)
(fold-right (lambda (x y) <??>) nil sequence))
(define (reverse sequence)
(fold-left (lambda (x y) <??>) nil sequence))
SOLUTION
The code and tests are here.
Comments
Post a Comment