Mercurial > hg > xemacs-beta
comparison man/lispref/functions.texi @ 444:576fb035e263 r21-2-37
Import from CVS: tag r21-2-37
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:36:19 +0200 |
parents | 9d177e8d4150 |
children | 6780963faf78 |
comparison
equal
deleted
inserted
replaced
443:a8296e22da4e | 444:576fb035e263 |
---|---|
1 @c -*-texinfo-*- | 1 @c -*-texinfo-*- |
2 @c This is part of the XEmacs Lisp Reference Manual. | 2 @c This is part of the XEmacs Lisp Reference Manual. |
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. | 3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. |
4 @c See the file lispref.texi for copying conditions. | 4 @c See the file lispref.texi for copying conditions. |
5 @setfilename ../../info/functions.info | 5 @setfilename ../../info/functions.info |
6 @node Functions, Macros, Variables, Top | 6 @node Functions, Macros, Variables, Top |
7 @chapter Functions | 7 @chapter Functions |
8 | 8 |
15 * Lambda Expressions:: How functions are expressed as Lisp objects. | 15 * Lambda Expressions:: How functions are expressed as Lisp objects. |
16 * Function Names:: A symbol can serve as the name of a function. | 16 * Function Names:: A symbol can serve as the name of a function. |
17 * Defining Functions:: Lisp expressions for defining functions. | 17 * Defining Functions:: Lisp expressions for defining functions. |
18 * Calling Functions:: How to use an existing function. | 18 * Calling Functions:: How to use an existing function. |
19 * Mapping Functions:: Applying a function to each element of a list, etc. | 19 * Mapping Functions:: Applying a function to each element of a list, etc. |
20 * Anonymous Functions:: Lambda expressions are functions with no names. | 20 * Anonymous Functions:: Lambda expressions are functions with no names. |
21 * Function Cells:: Accessing or setting the function definition | 21 * Function Cells:: Accessing or setting the function definition |
22 of a symbol. | 22 of a symbol. |
23 * Inline Functions:: Defining functions that the compiler will open code. | 23 * Inline Functions:: Defining functions that the compiler will open code. |
24 * Related Topics:: Cross-references to specific Lisp primitives | 24 * Related Topics:: Cross-references to specific Lisp primitives |
25 that have a special bearing on how functions work. | 25 that have a special bearing on how functions work. |
669 | 669 |
670 @defun identity arg | 670 @defun identity arg |
671 This function returns @var{arg} and has no side effects. | 671 This function returns @var{arg} and has no side effects. |
672 @end defun | 672 @end defun |
673 | 673 |
674 @defun ignore &rest args | 674 @deffn Command ignore &rest args |
675 This function ignores any arguments and returns @code{nil}. | 675 This function ignores any arguments and returns @code{nil}. |
676 @end defun | 676 @end deffn |
677 | 677 |
678 @node Mapping Functions | 678 @node Mapping Functions |
679 @section Mapping Functions | 679 @section Mapping Functions |
680 @cindex mapping functions | 680 @cindex mapping functions |
681 | 681 |
716 @group | 716 @group |
717 (defun mapcar* (f &rest args) | 717 (defun mapcar* (f &rest args) |
718 "Apply FUNCTION to successive cars of all ARGS. | 718 "Apply FUNCTION to successive cars of all ARGS. |
719 Return the list of results." | 719 Return the list of results." |
720 ;; @r{If no list is exhausted,} | 720 ;; @r{If no list is exhausted,} |
721 (if (not (memq 'nil args)) | 721 (if (not (memq 'nil args)) |
722 ;; @r{apply function to @sc{car}s.} | 722 ;; @r{apply function to @sc{car}s.} |
723 (cons (apply f (mapcar 'car args)) | 723 (cons (apply f (mapcar 'car args)) |
724 (apply 'mapcar* f | 724 (apply 'mapcar* f |
725 ;; @r{Recurse for rest of elements.} | 725 ;; @r{Recurse for rest of elements.} |
726 (mapcar 'cdr args))))) | 726 (mapcar 'cdr args))))) |
727 @end group | 727 @end group |
728 | 728 |
729 @group | 729 @group |
741 other suitable punctuation. | 741 other suitable punctuation. |
742 | 742 |
743 The argument @var{function} must be a function that can take one | 743 The argument @var{function} must be a function that can take one |
744 argument and return a string. The argument @var{sequence} can be any | 744 argument and return a string. The argument @var{sequence} can be any |
745 kind of sequence; that is, a list, a vector, a bit vector, or a string. | 745 kind of sequence; that is, a list, a vector, a bit vector, or a string. |
746 | 746 |
747 @smallexample | 747 @smallexample |
748 @group | 748 @group |
749 (mapconcat 'symbol-name | 749 (mapconcat 'symbol-name |
750 '(The cat in the hat) | 750 '(The cat in the hat) |
751 " ") | 751 " ") |
929 You can test the voidness of a symbol's function definition with | 929 You can test the voidness of a symbol's function definition with |
930 @code{fboundp}. After you have given a symbol a function definition, you | 930 @code{fboundp}. After you have given a symbol a function definition, you |
931 can make it void once more using @code{fmakunbound}. | 931 can make it void once more using @code{fmakunbound}. |
932 | 932 |
933 @defun fboundp symbol | 933 @defun fboundp symbol |
934 This function returns @code{t} if the symbol has an object in its | 934 This function returns @code{t} if @var{symbol} has an object in its |
935 function cell, @code{nil} otherwise. It does not check that the object | 935 function cell, @code{nil} otherwise. It does not check that the object |
936 is a legitimate function. | 936 is a legitimate function. |
937 @end defun | 937 @end defun |
938 | 938 |
939 @defun fmakunbound symbol | 939 @defun fmakunbound symbol |
974 making an alternate name for a function.) | 974 making an alternate name for a function.) |
975 | 975 |
976 @item | 976 @item |
977 Giving a symbol a function definition that is not a list and therefore | 977 Giving a symbol a function definition that is not a list and therefore |
978 cannot be made with @code{defun}. For example, you can use @code{fset} | 978 cannot be made with @code{defun}. For example, you can use @code{fset} |
979 to give a symbol @code{s1} a function definition which is another symbol | 979 to give a symbol @var{symbol1} a function definition which is another symbol |
980 @code{s2}; then @code{s1} serves as an alias for whatever definition | 980 @var{symbol2}; then @var{symbol1} serves as an alias for whatever definition |
981 @code{s2} presently has. | 981 @var{symbol2} presently has. |
982 | 982 |
983 @item | 983 @item |
984 In constructs for defining or altering functions. If @code{defun} | 984 In constructs for defining or altering functions. If @code{defun} |
985 were not a primitive, it could be written in Lisp (as a macro) using | 985 were not a primitive, it could be written in Lisp (as a macro) using |
986 @code{fset}. | 986 @code{fset}. |