Arc Forumnew | comments | leaders | submitlogin
4 points by wfarr 5853 days ago | link | parent

In arc, this is denoted with the "." just like in Scheme.

For example, an argument list for '+ might look like so:

  (a b . rest)
'rest would take the value of everything after '(a b).


3 points by cchooper 5853 days ago | link

Just to add: if you want your function to take any number (including zero) arguments, then just use a symbol instead of an argument list, and all the arguments will be bound to that symbol.

  (def return-all-args x x)

  (return-all-args 1 2 3)
  => (1 2 3)

-----

1 point by krg 5849 days ago | link

globalrev, this stuff confused me at first too.

So if you have (def foo (a b . c) ...stuff...) and you call (foo 1 2 3 4 5), a is bound to 1, b is bound to 2, and c is bound to the list (3 4 5).

And (def foo a ...stuff...) is just shorthand for (def foo ( . a) ...stuff...). So calling (foo 1 2 3) in this case means a is bound to the list (1 2 3).

-----

3 points by almkglor 5849 days ago | link

> And (def foo a ...stuff...) is just shorthand for (def foo ( . a) ...stuff...).

Technically wrong: ( . a) is invalid syntax. However it does help to think of it that way.

-----