Created
April 9, 2015 00:03
-
-
Save kouddy/8ebf6cf7caf5520b7d78 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
;;; 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