From: Eli Zaretskii Date: Mon, 20 Oct 2008 10:22:16 +0000 (+0000) Subject: (Calling Functions): Wording fixes from RMS. X-Git-Tag: emacs-pretest-23.0.90~2337 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a18a6d497c03fd2c5bf229058ba4faaa2d5c2f42;p=emacs.git (Calling Functions): Wording fixes from RMS. --- diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi index 4609fc18cef..e420e932fc7 100644 --- a/doc/lispref/functions.texi +++ b/doc/lispref/functions.texi @@ -727,7 +727,7 @@ of mapcar}. @cindex partial application of functions @cindex currying - Sometimes, it is useful to fix some of the function's arguments at + Sometimes it is useful to fix some of the function's arguments at certain values, and leave the rest of arguments for when the function is actually called. The act of fixing some of the function's arguments is called @dfn{partial application} of the function@footnote{ @@ -737,7 +737,9 @@ it can be called as a chain of functions, each one with a single argument.}. The result is a new function that accepts the rest of arguments and calls the original function with all the arguments -combined. Emacs provides a function for partial evaluation: +combined. + + Here's how to do partial application in Emacs Lisp: @defun apply-partially func &rest args This function returns a new function which, when called, will call @@ -747,14 +749,14 @@ accepts @var{n} arguments, then a call to @code{apply-partially} with @w{@code{@var{m} < @var{n}}} arguments will produce a new function of @w{@code{@var{n} - @var{m}}} arguments. -Here's an example of using @code{apply-partially} to produce a -function @code{incr}, that will increment its argument by one, based -on the Emacs Lisp primitive @code{+}: +Here's an example of using @code{apply-partially} to produce a variant +of the Emacs Lisp primitive @code{1+}, a function that increments its +argument by one, based on the primitive @code{+}: @example -(fset 'incr (apply-partially '+ 1)) +(fset 'incr-by-one (apply-partially '+ 1)) @group -(incr 10) +(incr-by-one 10) @result{} 11 @end group @end example