hi

how do they do variable length arguments in the old days? (using only

lambda)

I don't think it's possible in the really old days, they probably just

used a single list...

;; this seems to be the new syntax with the dot

(define sum (lambda (x . y) (apply + x y)))

(sum 1 2 3 4 5)

my toy interpreter can't handle this after I've been tweaking it for

one day. I'm sorta giving up.

new interpreters can do this weird thing:

((lambda x (cons x 'b)) 'a) , which is different from

((lambda (x) (cons x 'b)) 'a)

strange...

dillog

@gmail.com wrote:

> how do they do variable length arguments in the old days? (using only

> lambda)

> [...]

> ;; this seems to be the new syntax with the dot

> (define sum (lambda (x . y) (apply + x y)))

> (sum 1 2 3 4 5)

This is in fact the syntax using "only lambda". You could also

write (define (sum x . y) (apply + x y)).

> ((lambda x (cons x 'b)) 'a) , which is different from

((lambda x x)) => ()

((lambda x x) 1) => (1)

((lambda x x) 1 2) => (1 2)

...

See the pattern?

> ((lambda (x) (cons x 'b)) 'a)

((lambda (x) x)) => wrong!

((lambda (x) x) 1) => (1)

((lambda (x) x) 1 2) => wrong!

(define (f . x) ...) = (define f (lambda x ...))

--

Nils M Holm <n m h @ t 3 x . o r g> -- http://t3x.org/nmh/