Short after sending my message, I realized that I have shown too much. Apology. Wont happen again. Jos.
> -----Original Message----- > From: Martin DeMello [mailto:[email protected]] > Sent: 20 July 2010 17:21 > To: Jos Koot > Cc: PLT-Scheme Mailing List > Subject: Re: [racket] sicp exercise 2.20 > > Ah, nice :) Thanks! > > martin > > On Tue, Jul 20, 2010 at 8:39 PM, Jos Koot > <[email protected]> wrote: > > Yet another one using -apply-: > > > > (define (same-parity x . xs) > > (cond > > ((null? xs) (list x)) > > ((equal? (even? x) (even? (car xs))) (cons x (apply same-parity > > xs))) > > (else (apply same-parity x (cdr xs))))) > > > > Jos > > > >> -----Original Message----- > >> From: [email protected] > >> [mailto:[email protected]] On Behalf Of Martin DeMello > >> Sent: 20 July 2010 15:37 > >> To: PLT-Scheme Mailing List > >> Subject: [racket] sicp exercise 2.20 > >> > >> 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 > >> _________________________________________________ > >> For list-related administrative tasks: > >> http://lists.racket-lang.org/listinfo/users > > > > > > _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users

