Mercurial > emacs
changeset 98931:8bd819e4a411
(Calling Functions): Wording fixes from RMS.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Mon, 20 Oct 2008 10:22:16 +0000 |
parents | 61098e7c9344 |
children | 6e980913f210 |
files | doc/lispref/functions.texi |
diffstat | 1 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/lispref/functions.texi Mon Oct 20 10:10:56 2008 +0000 +++ b/doc/lispref/functions.texi Mon Oct 20 10:22:16 2008 +0000 @@ -727,7 +727,7 @@ @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 @@ 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 @@ @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