(define (same-parity x . z)
(define (q? y) (= (remainder y 2) 1))
(define (o? y) (= (remainder y 2) 0))
(define (jg z f)
(define m '())
(define (je a f m)
(if (f (car a))
(append m (list (car a)))
m))
(if (null? (cdr z))
(je z f m)
(append (je z f m) (jg (cdr z) f))))
(if (q? x)
(append (list x) (jg z q?))
(append (list x) (jg z o?))))