Skip to content

Instantly share code, notes, and snippets.

@yao2030
Created December 10, 2012 14:01
Show Gist options
  • Save yao2030/4250721 to your computer and use it in GitHub Desktop.
Save yao2030/4250721 to your computer and use it in GitHub Desktop.
(define (same-parity a . b)
(let ((test (if (even? a)
even?
odd?)))
(cons a (parity a test b))))
(define (parity a test b)
(cond ((and (not (null? b))(test (car b))) (cons (car b) (parity a test (cdr b) )))
((null? b) '())
(else (parity a test (cdr b) ))))
@yao2030
Copy link
Author

yao2030 commented Dec 10, 2012

SICP exercise 2.20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment