Skip to content

Instantly share code, notes, and snippets.

@kouddy
Created April 9, 2015 00:51
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 kouddy/4ea32a28421bbd4b3ece to your computer and use it in GitHub Desktop.
Save kouddy/4ea32a28421bbd4b3ece to your computer and use it in GitHub Desktop.
;;; 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