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.

Comments

Popular posts from this blog

SICP Exercise 4.18 a alternative strategy for interpreting internal definitions

SICP Exercise 3.11 make-account internal definitions with local state

SICP Exercise 3.13 make-cycle