Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;; d)
- ;; (nreverse nlist) consumes a Nested-Listof-Any nlist and reverses
- ;; every nested list
- ;; nreverse: Nested-Listof-Any -> Nested-Listof-Any
- ;; Examples:
- (check-expect (nreverse (list 1 3 (list 7 9))) (list (list 9 7) 3 1))
- (check-expect (nreverse empty) empty)
- (define (nreverse nlist)
- (nfoldr (lambda (x y) (append y (list x)))
- (lambda (x y) (append y (list x)))
- empty
- nlist))
- ;; Test:
- (check-expect (nreverse (list (list 1 2)(list 3 4))) (list (list 4 3)(list 2 1)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement