You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(fold-right (lambda (x y) (append y (list x))) nil sequence))
(define (reverse sequence)
(fold-left (lambda (x y) (cons y x)) nil sequence))
\endtt
Notice that the `reverse` procedure defined in terms of `fold-right` is very inefficient, because it generates a process that requires a number of steps proportional to the square of the length of the given sequence; instead the procedure defined in terms of `fold-left` generates a linear iterative process.