Reputation: 23826
Instead of this:
((lambda (a b) (apply '+ (list a b)))
1 2)
it is possible to write this in Scheme:
((lambda args (apply '+ args))
1 2)
Now it is possible to pass more than two arguments to the function.
When I try it in Emacs Lisp I get the error: invalid function.
How to define this function in Emacs Lisp?
Upvotes: 2
Views: 1117
Reputation: 41568
In Emacs Lisp, you can put &rest
in the argument list of the function, to get the remaining arguments as a list:
(lambda (&rest args) (apply '+ args))
Upvotes: 2