Author Topic: [Scheme/Lisp] Purpose/use of procedures that take arbitrary amount of arguments  (Read 3235 times)

0 Members and 1 Guest are viewing this topic.

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
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?

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
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*

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Figured it out

(it's the apply procedure)

And yeah, I've been away for a while, haven't I?

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Yup, nice to see you back. I hope you stick around. ;)