[BACK]Return to function.texi CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-doc / parts / builtin

Annotation of OpenXM/src/asir-doc/parts/builtin/function.texi, Revision 1.5

1.5     ! ohara       1: @comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/function.texi,v 1.4 2003/04/20 08:01:28 noro Exp $
1.2       noro        2: \BJP
1.1       noro        3: @node $BH!?t$KBP$9$kA`:n(B,,, $BAH$_9~$_H!?t(B
                      4: @section $BH!?t$KBP$9$kA`:n(B
1.2       noro        5: \E
                      6: \BEG
                      7: @node Operations on functions,,, Built-in Function
                      8: @section Operations on functions
                      9: \E
1.1       noro       10:
                     11: @menu
1.5     ! ohara      12: * call::
1.1       noro       13: * functor args funargs::
                     14: @end menu
1.5     ! ohara      15:
        !            16: \JP @node call,,, $BH!?t$KBP$9$kA`:n(B
        !            17: \EG @node call,,, Operations on functions
        !            18: @subsection @code{call}
        !            19: @findex call
        !            20:
        !            21: @table @t
        !            22: @item call(@var{name}, @var{args})
        !            23: \JP :: $BH!?t(B @var{name} $B$r8F$S=P$9(B.
        !            24: \EG :: Call the function @var{name} with @var{args}.
        !            25: @end table
        !            26:
        !            27: @table @var
        !            28: @item return
        !            29: \JP $BH!?t(B @code{name()} $B$NJV$jCM(B.
        !            30: \EG a return value of @code{name()}.
        !            31: @item name
        !            32: \JP $BH!?tL>$rI=$9ITDj85(B($BH!?t;R$H$O8B$i$J$$(B)
        !            33: \EG indefinite (function name)
        !            34: @item args
        !            35: \JP $B0z?t$N%j%9%H(B
        !            36: \EG a list of arguments
        !            37: @end table
        !            38:
        !            39: @itemize @bullet
        !            40: \BJP
        !            41: @item
        !            42: $BH!?t;R$K4X$7$F$O(B, @code{vtype()} $B$r;2>H(B.
        !            43: @item
        !            44: $B0z?t$N8D?t$,$"$i$+$8$aJ,$+$C$F$$$k$H$-$O(B @code{(*@var{name})()} $B$N7A<0(B,
        !            45: $BJ,$+$i$J$$$H$-$O(B @code{call()} $B$r;H$&$H$h$$(B.
        !            46: \E
        !            47: \BEG
        !            48: @item
        !            49: See @ref{vtype} for function form.
        !            50: \E
        !            51: @end itemize
        !            52:
        !            53: @example
        !            54: [0] A=igcd;
        !            55: igcd
        !            56: [1] call(A,[4,6]);
        !            57: 2
        !            58: [2] (*A)(4,6);
        !            59: 2
        !            60: @end example
        !            61:
        !            62: @table @t
        !            63: \JP @item $B;2>H(B
        !            64: \EG @item References
        !            65: @fref{vtype}.
        !            66: @end table
1.1       noro       67:
1.2       noro       68: \JP @node functor args funargs,,, $BH!?t$KBP$9$kA`:n(B
                     69: \EG @node functor args funargs,,, Operations on functions
1.1       noro       70: @subsection @code{functor}, @code{args}, @code{funargs}
                     71: @findex functor
                     72: @findex args
                     73: @findex funargs
                     74:
                     75: @table @t
                     76: @item functor(@var{func})
1.2       noro       77: \JP :: @var{func} $B$NH!?t;R$r<h$j=P$9(B.
                     78: \EG :: Functor of function form @var{func}.
1.1       noro       79: @item args(@var{func})
1.2       noro       80: \JP :: @var{func} $B$N0z?t%j%9%H$r<h$j=P$9(B.
                     81: \EG :: List of arguments of function form @var{func}.
1.1       noro       82: @item funargs(@var{func})
1.2       noro       83: \JP :: @code{cons(functor(@var{func}),args(@var{func}))} $B$rJV$9(B.
                     84: \EG :: @code{cons(functor(@var{func}),args(@var{func}))}.
1.1       noro       85: @end table
                     86:
                     87: @table @var
                     88: @item return
1.2       noro       89: \JP @code{functor()} : $BITDj85(B, @code{args()}, @code{funargs()} : $B%j%9%H(B
                     90: \EG @code{functor()} : indeterminate, @code{args()}, @code{funargs()} : list
1.1       noro       91: @item func
1.2       noro       92: \JP $BH!?t7A<0$rI=$9ITDj85(B
                     93: \EG function form
1.1       noro       94: @end table
                     95:
                     96: @itemize @bullet
1.2       noro       97: \BJP
1.1       noro       98: @item
                     99: $BH!?t7A<0$K4X$7$F$O(B, @code{vtype()} $B$r;2>H(B.
                    100: @item
                    101: $BH!?t7A<0(B @var{func} $B$NH!?t;R(B, $B0z?t%j%9%H$r<h$j=P$9(B.
                    102: @item
                    103: $B5U$K(B, $B<h$j=P$7$?H!?t;R$rCM$K;}$D%W%m%0%i%`JQ?t$r(B @code{F} $B$H$9$l$P(B (@code{*F})(x) $B$G(B
                    104: x $B$r0z?t$H$9$kH!?t8F$S=P$7$^$?$OH!?t7A<0$,F~NO$G$-$k(B.
1.2       noro      105: \E
                    106: \BEG
                    107: @item
1.3       noro      108: See @ref{vtype} for function form.
1.2       noro      109: @item
                    110: Extract the functor and  the arguments of function form @var{func}.
                    111: @item
                    112: Assign a program variable, say @code{F}, to the functor obtained
                    113: by @code{functor()}.  Then, you can type (@code{*F})(x)
                    114: (, or (@code{*F})(x,y,...)
                    115: depending on the arity,) to input a function form with argument x.
                    116: \E
1.1       noro      117: @end itemize
                    118:
                    119: @example
                    120: [0] functor(sin(x));
                    121: sin
                    122: [0] args(sin(x));
                    123: [x]
                    124: [0] funargs(sin(3*cos(y)));
                    125: [sin,3*cos(y)]
1.4       noro      126: [1] for (L=[sin,cos,tan];L!=[];L=cdr(L)) @{A=car(L);
                    127: print(eval((*A)(@@pi/3)));@}
1.1       noro      128: 0.86602540349122136831
                    129: 0.5000000002
                    130: 1.7320508058
                    131: @end example
                    132:
                    133: @table @t
1.2       noro      134: \JP @item $B;2>H(B
                    135: \EG @item References
1.1       noro      136: @fref{vtype}.
                    137: @end table
                    138:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>