diff options
| author | Eli Zaretskii | 2008-10-20 10:22:16 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2008-10-20 10:22:16 +0000 |
| commit | a18a6d497c03fd2c5bf229058ba4faaa2d5c2f42 (patch) | |
| tree | 98a72f247cc8b811a1489ae27788c734958cf184 | |
| parent | 712adc825a352cb6a8c2ce83e49a18a178d8cdaa (diff) | |
| download | emacs-a18a6d497c03fd2c5bf229058ba4faaa2d5c2f42.tar.gz emacs-a18a6d497c03fd2c5bf229058ba4faaa2d5c2f42.zip | |
(Calling Functions): Wording fixes from RMS.
| -rw-r--r-- | doc/lispref/functions.texi | 16 |
1 files changed, 9 insertions, 7 deletions
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}. | |||
| 727 | 727 | ||
| 728 | @cindex partial application of functions | 728 | @cindex partial application of functions |
| 729 | @cindex currying | 729 | @cindex currying |
| 730 | Sometimes, it is useful to fix some of the function's arguments at | 730 | Sometimes it is useful to fix some of the function's arguments at |
| 731 | certain values, and leave the rest of arguments for when the function | 731 | certain values, and leave the rest of arguments for when the function |
| 732 | is actually called. The act of fixing some of the function's | 732 | is actually called. The act of fixing some of the function's |
| 733 | arguments is called @dfn{partial application} of the function@footnote{ | 733 | 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 | |||
| 737 | argument.}. | 737 | argument.}. |
| 738 | The result is a new function that accepts the rest of | 738 | The result is a new function that accepts the rest of |
| 739 | arguments and calls the original function with all the arguments | 739 | arguments and calls the original function with all the arguments |
| 740 | combined. Emacs provides a function for partial evaluation: | 740 | combined. |
| 741 | |||
| 742 | Here's how to do partial application in Emacs Lisp: | ||
| 741 | 743 | ||
| 742 | @defun apply-partially func &rest args | 744 | @defun apply-partially func &rest args |
| 743 | This function returns a new function which, when called, will call | 745 | 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 | |||
| 747 | @w{@code{@var{m} < @var{n}}} arguments will produce a new function of | 749 | @w{@code{@var{m} < @var{n}}} arguments will produce a new function of |
| 748 | @w{@code{@var{n} - @var{m}}} arguments. | 750 | @w{@code{@var{n} - @var{m}}} arguments. |
| 749 | 751 | ||
| 750 | Here's an example of using @code{apply-partially} to produce a | 752 | Here's an example of using @code{apply-partially} to produce a variant |
| 751 | function @code{incr}, that will increment its argument by one, based | 753 | of the Emacs Lisp primitive @code{1+}, a function that increments its |
| 752 | on the Emacs Lisp primitive @code{+}: | 754 | argument by one, based on the primitive @code{+}: |
| 753 | 755 | ||
| 754 | @example | 756 | @example |
| 755 | (fset 'incr (apply-partially '+ 1)) | 757 | (fset 'incr-by-one (apply-partially '+ 1)) |
| 756 | @group | 758 | @group |
| 757 | (incr 10) | 759 | (incr-by-one 10) |
| 758 | @result{} 11 | 760 | @result{} 11 |
| 759 | @end group | 761 | @end group |
| 760 | @end example | 762 | @end example |