Reverse in terms of folds

Complete the following definitions of reverse (exercise 2.18 ) in terms of fold-right and fold-left from exercise 2.38 :

(define (reverse-right sequence)
  (fold-right (lambda (x y) <??>) nil sequence))

(define (reverse-left sequence)
  (fold-left (lambda (x y) <??>) nil sequence))

There are no comments yet.

Authentication required

You must log in to post a comment.

Login
(define example (list 1 2 3 4 5))

(check-equal? (reverse-right example) (list 5 4 3 2 1))
(check-equal? (reverse-left example) (reverse-right example))