;#!/usr/bin/racket
;#lang scheme
(define (same-parity a . xs)
(define parity (remainder a 2))
(define (iter items result)
(if (null? items)
result
(iter (cdr items)
(if (= (remainder (car items) 2) parity)
(cons result (car items))
result))))
(iter xs (list a)))
; Testing
(define x (list 1 2 3 4 5 6 7 8 9 10))
(display (same-parity 1 x))
(display)
OyMhL3Vzci9iaW4vcmFja2V0CjsjbGFuZyBzY2hlbWUKCgoKKGRlZmluZSAoc2FtZS1wYXJpdHkgYSAuIHhzKQogICAgICAgIChkZWZpbmUgcGFyaXR5IChyZW1haW5kZXIgYSAyKSkKICAgICAgICAoZGVmaW5lIChpdGVyIGl0ZW1zIHJlc3VsdCkKICAgICAgICAgICAgICAgIChpZiAobnVsbD8gaXRlbXMpCiAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdAogICAgICAgICAgICAgICAgICAgICAgICAoaXRlciAoY2RyIGl0ZW1zKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoaWYgKD0gKHJlbWFpbmRlciAoY2FyIGl0ZW1zKSAyKSBwYXJpdHkpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGNvbnMgcmVzdWx0IChjYXIgaXRlbXMpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCkpKSkKICAgICAgICAoaXRlciB4cyAobGlzdCBhKSkpCgo7IFRlc3RpbmcKKGRlZmluZSB4IChsaXN0IDEgMiAzIDQgNSA2IDcgOCA5IDEwKSkKCihkaXNwbGF5IChzYW1lLXBhcml0eSAxIHgpKQooZGlzcGxheSkK