1 |
@c -*-texinfo-*- |
@c -*-texinfo-*- |
2 |
@c This is part of the GNU Emacs Lisp Reference Manual. |
@c This is part of the GNU Emacs Lisp Reference Manual. |
3 |
@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999 |
@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999 |
4 |
@c Free Software Foundation, Inc. |
@c Free Software Foundation, Inc. |
5 |
@c See the file elisp.texi for copying conditions. |
@c See the file elisp.texi for copying conditions. |
6 |
@setfilename ../info/functions |
@setfilename ../info/functions |
7 |
@node Functions, Macros, Variables, Top |
@node Functions, Macros, Variables, Top |
18 |
* Defining Functions:: Lisp expressions for defining functions. |
* Defining Functions:: Lisp expressions for defining functions. |
19 |
* Calling Functions:: How to use an existing function. |
* Calling Functions:: How to use an existing function. |
20 |
* Mapping Functions:: Applying a function to each element of a list, etc. |
* Mapping Functions:: Applying a function to each element of a list, etc. |
21 |
* Anonymous Functions:: Lambda expressions are functions with no names. |
* Anonymous Functions:: Lambda expressions are functions with no names. |
22 |
* Function Cells:: Accessing or setting the function definition |
* Function Cells:: Accessing or setting the function definition |
23 |
of a symbol. |
of a symbol. |
24 |
* Inline Functions:: Defining functions that the compiler will open code. |
* Inline Functions:: Defining functions that the compiler will open code. |
746 |
"Apply FUNCTION to successive cars of all ARGS. |
"Apply FUNCTION to successive cars of all ARGS. |
747 |
Return the list of results." |
Return the list of results." |
748 |
;; @r{If no list is exhausted,} |
;; @r{If no list is exhausted,} |
749 |
(if (not (memq 'nil args)) |
(if (not (memq 'nil args)) |
750 |
;; @r{apply function to @sc{car}s.} |
;; @r{apply function to @sc{car}s.} |
751 |
(cons (apply function (mapcar 'car args)) |
(cons (apply function (mapcar 'car args)) |
752 |
(apply 'mapcar* function |
(apply 'mapcar* function |
753 |
;; @r{Recurse for rest of elements.} |
;; @r{Recurse for rest of elements.} |
754 |
(mapcar 'cdr args))))) |
(mapcar 'cdr args))))) |
755 |
@end group |
@end group |
779 |
argument and return a string. The argument @var{sequence} can be any |
argument and return a string. The argument @var{sequence} can be any |
780 |
kind of sequence except a char-table; that is, a list, a vector, a |
kind of sequence except a char-table; that is, a list, a vector, a |
781 |
bool-vector, or a string. |
bool-vector, or a string. |
782 |
|
|
783 |
@smallexample |
@smallexample |
784 |
@group |
@group |
785 |
(mapconcat 'symbol-name |
(mapconcat 'symbol-name |
841 |
the function @code{mapcar}, which applies any given function to each |
the function @code{mapcar}, which applies any given function to each |
842 |
element of a list. |
element of a list. |
843 |
|
|
844 |
Here we define a function @code{change-property} which |
Here we define a function @code{change-property} which |
845 |
uses a function as its third argument: |
uses a function as its third argument: |
846 |
|
|
847 |
@example |
@example |
915 |
|
|
916 |
@cindex @samp{#'} syntax |
@cindex @samp{#'} syntax |
917 |
The read syntax @code{#'} is a short-hand for using @code{function}. |
The read syntax @code{#'} is a short-hand for using @code{function}. |
918 |
For example, |
For example, |
919 |
|
|
920 |
@example |
@example |
921 |
#'(lambda (x) (* x x)) |
#'(lambda (x) (* x x)) |