Skip to content

Instantly share code, notes, and snippets.

@smly
Created October 6, 2008 05:12
Show Gist options
  • Save smly/14989 to your computer and use it in GitHub Desktop.
Save smly/14989 to your computer and use it in GitHub Desktop.
; 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