Created
October 6, 2008 05:12
-
-
Save smly/14989 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
; Exercise 2.20 | |
(define (same-pair x . b) | |
(define (is-same-parity? x y) | |
(or (and (even? x) (even? y)) | |
(and (odd? x) (odd? y)))) | |
(define (same-pair-recur items) | |
(if (null? items) | |
'() | |
(if (is-same-parity? x (car items)) | |
(cons (car items) (same-pair-recur (cdr items))) | |
(same-pair-recur (cdr items))))) | |
(cons x (same-pair-recur b))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment