Recall reverse and add-at-end:

;; reverse : list-of-numbers -> list-of-numbers
(define (reverse l)
    [(empty? l) empty]
    [else (add-at-end (first l) (reverse (rest l)))]))

;; add-at-end : number list-of-numbers -> list-of-numbers
(define (add-at-end ele l)
    [(empty? l) (list ele)]
    [else (cons (first l) (add-at-end ele (rest l)))]))

Rewrite these functions, using fold:

;; fold : list-of-X Y (X Y -> Y) -> Y
(define (fold l base combine)
    [(empty? l) base]
    [else (combine (first l) (fold (rest l) base combine))]))

For each use of fold, identify what X and Y from fold's type are.



(define (reverse l) (fold l empty add-at-end))
(define (add-at-end ele l) (fold l (list ele) cons))

In both cases, X is number and Y is list-of-numbers.