(lambda (head . rest)
(...))
I encountered this code on the net when trying to learn some scheme, but I couldn’t find any useful explanation.
What is the meaning of this? Is it some kind of pattern matching as in ML?
(Btw they apply this lambda to only one argument!)
In this procedure:
The syntax indicates that the
lambdaform is expecting one mandatory argument bound to the nameargand a list with zero or more elements (a variable number of arguments) bound to the nameargs. 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: