What does the &rest
mean in this: (append &rest sequences)
I have finished the book "elisp_intro",but I didn't find the answer. I will be very grateful if you can help me.
It indicates that the following argument is the "rest" argument. In the case of your example, sequences
is the rest argument.
Unlike a normal argument, the rest argument will consume the "rest" of any parameters provided by the user. It is a way of making a function that accepts a variable number of arguments. Inside the function body, the argument will be a list containing all of the extra parameters.
So if you had a function that looked like (add &rest numbers)
, then you could call it like (add 1 2 3 4 5)
, and within the function the numbers
argument would have the value (1 2 3 4 5)
.
Or for example, ((lambda (a &rest r) r) 1 2 3) ;=> (2 3)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With