[plt-scheme] lambda argument lists that contain only a rest argument

From: Jon Zeppieri (zeppieri at gmail.com)
Date: Thu Mar 22 01:30:48 EDT 2007

On 3/22/07, Ethan Herdrick <info at reatlas.com> wrote:
> Why is this OK:
> (define (rest-only . r)
>   r)
>
> But this can't even be read into the interpreter:
> (define rest-only
>   (λ ( . r)
>     r))
>

The former is equivalent to:

(define rest-only (λ r r))

...not:

(define rest-only (λ ( . r) r))

...which, as you've noticed, is a syntax error.


(λ x ...) is a procedure that takes any number of arguments.
(λ (x . y) ...) is a procedure that takes at least one argument.
(λ (x y . z) ...) is procedure that takes at least two arguments.

(define (foo . x) ...) defines a procedure foo, which takes any number
of arguments.
(define (foo x . y) ...) defines a procedure foo, which takes at least
one argument.

... and so forth.

Posted on the users mailing list.