;; list-append: list, list -> list ;; the function takes a list and returns ;; a new list which consists of all the elements ;; of the first list followed by all the elements ;; of the second list ;; Examples: ;; (list-append (list 5 6 7) (list 3 6 0)) -> (list 5 6 7 3 6 0) ;; (list-append empty (list 5 6 7)) -> (list 5 6 7) (define (list-append list1 list2) (cond [(empty? list1) list2] [else (cons (first list1) (list-append (rest list1) list2))] ) ) (check-expect (list-append empty (list 5 6 7)) (list 5 6 7)) (check-expect (list-append (list 5 6 7) empty) (list 5 6 7)) (check-expect (list-append (list 5 6 7) (list 3 6 0)) (list 5 6 7 3 6 0)) ;; list-reverse: list -> list ;; the function takes a list and returns a list ;; of the same elements, but in reverse order ;; Example: ;; (list-reverse (list 1 2 3 4 5)) -> (list 5 4 3 2 1) (define (list-reverse a-list) (cond [(empty? a-list) empty] [else (list-append (list-reverse (rest a-list)) (list (first a-list)))] ) ) (check-expect (list-reverse empty) empty) (check-expect (list-reverse (list 3)) (list 3)) (check-expect (list-reverse (list 1 2 3 4 5)) (list 5 4 3 2 1))