Created
December 11, 2012 01:48
-
-
Save yao2030/4255082 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(define (last-pair list1) | |
(if (= (length list1) 1) | |
(car list1) | |
(last-pair (cdr list1)))) | |
(define (but-last list1) | |
(if (= (length list1) 1) | |
'() | |
(cons (car list1) (but-last (cdr list1))))) | |
(define (reverse x) | |
(if (null? x) | |
'() | |
(cons (last-pair x) (reverse (but-last x))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment