[plt-scheme] dot notation issue

From: Richard Cleis (rcleis at mac.com)
Date: Fri Feb 6 20:17:36 EST 2009

To find out what is going on, make a function like same-parity that  
simply returns the dotted x.  Then, try it in the interactions window  
to see what the function gets for x.  Use arguments that are like the  
ones you expect to be created in same-parity.

rac

On Feb 6, 2009, at 4:46 PM, Lisa Gandy wrote:

> Hi,
> I have the following code..
>
> (define (same-parity p . x)
>     (define ind (remainder p 2))
>     (cond ((null? x) '())
>           ((= ind (remainder (car x) 2))
>           (cons (car x) (same-parity p (cdr x))))
>           (else (same-parity p (cdr x)))))
>
> I thought that x would be passed in as a list however
> when I run this function I get...
> (require (lib "trace.ss"))
> > (trace same-parity)
> > (same-parity 1 2 3 4 5)
> |(same-parity 1 2 3 4 5)
> |(same-parity 1 (3 4 5))
>
> What is going on here?
>
> Thanks!
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090206/a5d95f5c/attachment.html>

Posted on the users mailing list.