Created
April 9, 2015 00:51
-
-
Save kouddy/4ea32a28421bbd4b3ece to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; recursion | |
(define (reverse items) | |
(if (null? items) | |
null | |
(cons (reverse (cdr items)) (car items)))) | |
;;; iteration | |
(define (reverse-iter items) | |
(define (iter i result) | |
(if (null? i) | |
result | |
(iter (cdr i) (cons (car i) result)))) | |
(iter items null)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment