[racket] can't cdr list from dotted-tail notation?

From: Pierpaolo Bernardi (olopierpa at gmail.com)
Date: Thu Nov 22 12:30:43 EST 2012

On Tue, Nov 20, 2012 at 10:46 PM, Sanjeev K Sharma <throwit1 at hotmail.com> wrote:
> I already spent a couple of hours on this, hope I am not missing something really obvious - does the dotted notation produce some kind of flat list instead of cons cells?
>
>
>
> (define list-rf (lambda ( n . items )
>   (if (= n 0)
>       (car items)
>       (list-rf (- n 1)(cdr items)))))

change the last line to:

(apply list-rf (- n 1) (cdr items)

In your version, the recursive calls get a one-element list as argument.

Cheers
P.

Posted on the users mailing list.