Skip to content

Instantly share code, notes, and snippets.

@tequilasunset
Created February 24, 2011 22:42
Show Gist options
  • Save tequilasunset/843057 to your computer and use it in GitHub Desktop.
Save tequilasunset/843057 to your computer and use it in GitHub Desktop.
(define (same-parity first . rest)
(define (collect lst test)
(if (null? lst)
'()
(let ((a (car lst)) (d (cdr lst)))
(if (test a)
(cons a (collect d test))
(collect d test)))))
(cons first
(collect rest (if (even? first) even? odd?))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment