In this procedure:
(lambda (arg . args)
(...))
The syntax indicates that the lambda
form is expecting one mandatory argument bound to the name arg
and a list with zero or more elements (a variable number of arguments) bound to the name args
. This is an example of a variadic function.
The same syntax can be used for named procedures, noticing that any number of parameters can be specified as mandatory and after that the rest are considered optional; take a look at this example:
(define (test arg . args)
(apply + arg args))
(test) ; will cause an error, at least one argument is expected
(test 10) ; returns 10
(test 10 4) ; returns 14
(test 10 4 2) ; returns 16