Guest User

Untitled

a guest
Feb 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. ; Exercise 2.20
  2. (define (same-pair x . b)
  3. (define (is-same-parity? x y)
  4. (or (and (even? x) (even? y))
  5. (and (odd? x) (odd? y))))
  6. (define (same-pair-recur items)
  7. (if (null? items)
  8. '()
  9. (if (is-same-parity? x (car items))
  10. (cons (car items) (same-pair-recur (cdr items)))
  11. (same-pair-recur (cdr items)))))
  12. (cons x (same-pair-recur b)))
Add Comment
Please, Sign In to add comment