Skip to content

Instantly share code, notes, and snippets.

@kouddy
Created April 9, 2015 00:03
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/8ebf6cf7caf5520b7d78 to your computer and use it in GitHub Desktop.
Save kouddy/8ebf6cf7caf5520b7d78 to your computer and use it in GitHub Desktop.
;;; Assuming at least 1 element in items
(define (last-pair items)
(if (null? (cdr items))
(car items)
(last-pair (cdr items))))
;;; Assuming at least 1 element in items
(define (last-pair-iter items)
(define (iter i result)
(if (null? i)
result
(iter (cdr i) (car i))))
(iter items (car items)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment