Omnimaga

General Discussion => Technology and Development => Computer Programming => Topic started by: squidgetx on October 12, 2013, 05:34:44 pm

Title: [Scheme/Lisp] Purpose/use of procedures that take arbitrary amount of arguments
Post by: squidgetx on October 12, 2013, 05:34:44 pm
In class (scheme) we recently learned about the syntax that allows a function to take an arbitrary amount of arguments eg;
Code: [Select]
(define len
  (lambda args
    (length args)))

>(len 1 2 3)
3
What are the advantages of using this form over simply passing the arguments as a single list in the first place? How do you even pass arguments to these kinds of functions within a program (and not on the command line)? Is there a way to make a procedure that returns a series of values that aren't wrapped within a list?
Title: Re: [Scheme/Lisp] Purpose/use of procedures that take arbitrary amount of arguments
Post by: Streetwalrus on October 13, 2013, 08:10:58 am
Well, I don't know Lisp and I don't know people who do so I can't help you. :/

Also how dare you post after a hiatus without updating us on A:P ? *runs*
Title: Re: [Scheme/Lisp] Purpose/use of procedures that take arbitrary amount of arguments
Post by: squidgetx on October 13, 2013, 09:37:52 pm
Figured it out

(it's the apply procedure)

And yeah, I've been away for a while, haven't I?
Title: Re: [Scheme/Lisp] Purpose/use of procedures that take arbitrary amount of arguments
Post by: Streetwalrus on October 14, 2013, 07:03:07 am
Yup, nice to see you back. I hope you stick around. ;)