Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Scheme Programming Language

how do they do variable length arguments in the old days?


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/

dillog@gmail.com writes:
> 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...

That's was possible in the really old days.  They just used a single list.

Check the sources in http://www.informatimago.com/develop/lisp/lisp15-0.0.tar.gz
search for: APPLY(F,L,A)

--
__Pascal Bourguignon__
http://www.informatimago.com
http://pjb.ogamita.org

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc