Skip to content

Instantly share code, notes, and snippets.

@kouddy
Created April 9, 2015 02:57
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/bf13fcef9cda8410a74e to your computer and use it in GitHub Desktop.
Save kouddy/bf13fcef9cda8410a74e to your computer and use it in GitHub Desktop.
(define (same-parity x . y)
(define (same-parity? a b)
(or (and (even? a) (even? b))
(and (odd? a) (odd? b))))
(define (rec y)
(cond ((null? y) null)
((same-parity? x (car y)) (cons (car y) (rec (cdr y))))
(else (rec (cdr y)))))
(cons x (rec y)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment