[racket] sicp exercise 2.20

From: Martin DeMello (martindemello at gmail.com)
Date: Tue Jul 20 09:36:54 EDT 2010

By way of a puzzle, I've been trying to solve SICP exercise 2.20
----------------------------
Using the (define (f x . args)) notation, write a procedure
"same-parity" that takes one or more integers and returns a list of
all the arguments that have the same even-odd parity as the first
argument. For example,
(same-parity 1 2 3 4 5 6 7)
(1 3 5 7)
(same-parity 2 3 4 5 6 7)
(2 4 6)
----------------------------
using "straight recursion", that is, without using any `let` or
`define` constructs. Still not managed to find the trick that will
tack on the first argument as the head of the list. Anyone have a
hint?

martin


Posted on the users mailing list.