Skip to content

Instantly share code, notes, and snippets.

@chelseatroy
Last active October 29, 2019 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chelseatroy/ad3921bf17ac06ed72f3146019246592 to your computer and use it in GitHub Desktop.
Save chelseatroy/ad3921bf17ac06ed72f3146019246592 to your computer and use it in GitHub Desktop.
List Reversal
; 2.18
(define (reverse list)
(define (iter-list reversed-list unprocessed-remaining)
(if (null? unprocessed-remaining)
reversed-list
(iter-list (cons(car unprocessed-remaining) reversed-list) (cdr unprocessed-remaining))
)
)
(iter-list null list))
(reverse (list 3 4 5 6)) ;---> 6 4 5 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment