Annotation of OpenXM/src/asir-doc/parts/builtin/string.texi, Revision 1.3
1.3 ! noro 1: @comment $OpenXM$
! 2: \BJP
1.1 noro 3: @node $BJ8;zNs$K4X$9$k1i;;(B,,, $BAH$_9~$_H!?t(B
4: @section $BJ8;zNs$K4X$9$k1i;;(B
1.3 ! noro 5: \E
! 6: \BEG
! 7: @node Strings,,, Built-in Function
! 8: @section Strings
! 9: \E
1.1 noro 10:
11: @menu
12: * rtostr::
13: * strtov::
1.2 noro 14: * eval_str::
1.1 noro 15: @end menu
16:
1.3 ! noro 17: \JP @node rtostr,,, $BJ8;zNs$K4X$9$k1i;;(B
! 18: \EG @node rtostr,,, Strings
1.1 noro 19: @subsection @code{rtostr}
20: @findex rtostr
21:
22: @table @t
23: @item rtostr(@var{obj})
1.3 ! noro 24: \JP :: @var{obj} $B$rJ8;zNs$KJQ$($k(B.
! 25: \EG :: Convert @var{obj} into a string.
1.1 noro 26: @end table
27:
28: @table @var
29: @item return
1.3 ! noro 30: \JP $BJ8;zNs(B
! 31: \EG string
1.1 noro 32: @item obj
1.3 ! noro 33: \JP $BG$0U(B
! 34: \EG arbitrary
1.1 noro 35: @end table
36:
37: @itemize @bullet
1.3 ! noro 38: \BJP
1.1 noro 39: @item
40: $BG$0U$N%*%V%8%'%/%H(B @var{obj} $B$rJ8;zNs$KJQ$($k(B.
41: @item
42: $B@0?t$J$I$rJ8;zNs$KJQ49$7$FJQ?tL>$H7k9g$9$k$3$H$K$h$j(B,
43: $BE:;zIU$-$NITDj85$r@8@.$9$k>l9g$KB?$/MQ$$$i$l$k(B.
44: @item
45: $B5U$K(B, $BJ8;zNs$rITDj85$KJQ49$9$k;~$K$O(B, @code{strtov} $B$rMQ$$$k(B.
1.3 ! noro 46: \E
! 47: \BEG
! 48: @item
! 49: Convert an arbitrary object @var{obj} into a string.
! 50: @item
! 51: This function is convenient to create variables with numbered
! 52: (or indexed) names by converting integers into strings and appending them
! 53: to some name strings.
! 54: @item
! 55: Use @code{strtov()} for inverse conversion from string to indeterminate.
! 56: \E
1.1 noro 57: @end itemize
58:
59: @example
60: [0] A=afo;
61: afo
62: [1] type(A);
63: 2
64: [2] B=rtostr(A);
65: afo
66: [3] type(B);
67: 7
68: [4] B+"1";
69: afo1
70: @end example
71:
72: @table @t
1.3 ! noro 73: \JP @item $B;2>H(B
! 74: \EG @item References
1.1 noro 75: @fref{strtov}, @fref{type}.
76: @end table
77:
1.3 ! noro 78: \JP @node strtov,,, $BJ8;zNs$K4X$9$k1i;;(B
! 79: \EG @node strtov,,, Strings
1.1 noro 80: @subsection @code{strtov}
81: @findex strtov
82:
83: @table @t
84: @item strtov(@var{str})
1.3 ! noro 85: \JP :: @var{str} ($BJ8;zNs(B) $B$rITDj85$KJQ$($k(B.
! 86: \EG :: Convert a string @var{str} into an indeterminate.
1.1 noro 87: @end table
88:
89: @table @var
90: @item return
1.3 ! noro 91: \JP $BITDj85(B
! 92: \EG intederminate
1.1 noro 93: @item str
1.3 ! noro 94: \JP $BITDj85$H$7$FJQ492DG=$JJ8;zNs(B
! 95: \EG string which is valid to constitute an indeterminate.
1.1 noro 96: @end table
97:
98: @itemize @bullet
1.3 ! noro 99: \BJP
1.1 noro 100: @item
101: $BITDj85$H$7$FJQ492DG=$JJ8;zNs$rITDj85$KJQ$($k(B.
102: @item
103: $BITDj85$H$7$FJQ492DG=$JJ8;zNs$H$O(B, $B1Q>.J8;z$G;O$^$j(B,
104: $B1Q;z(B, $B?t;z$*$h$S5-9f(B @code{_} $B$G:n$i$l$kJ8;zNs$G$"$k(B.
105: @item
106: @code{rtostr()} $B$HAH9g$;$F(B, $B%W%m%0%i%`Cf$G<+F0E*$KITDj85$r@8@.$7$?$$;~$K(B
107: $BMQ$$$i$l$k(B.
1.3 ! noro 108: \E
! 109: \BEG
! 110: @item
! 111: Convert a string that is valid for an indeterminate into an indeterminate
! 112: which have @var{str} as its print name.
! 113: @item
! 114: The valid string for an indeterminate is such a string that begins
! 115: with a small alphabetical letter possibly followed by any string composed
! 116: of alphabetical letters, digits or a symbol @samp{_}.
! 117: @item
! 118: Use the command to create indeterminates dynamically in programs.
! 119: \E
1.1 noro 120: @end itemize
121:
122: @example
123: [0] A="afo";
124: afo
125: [1] for (I=0;I<3;I++) @{B=strtov(A+rtostr(I)); print([B,type(B)]);@}
126: [afo0,2]
127: [afo1,2]
128: [afo2,2]
129: @end example
130:
131: @table @t
1.3 ! noro 132: \JP @item $B;2>H(B
! 133: \EG @item References
1.1 noro 134: @fref{rtostr}, @fref{type}, @fref{uc}.
1.2 noro 135: @end table
136:
1.3 ! noro 137: \JP @node eval_str,,, $BJ8;zNs$K4X$9$k1i;;(B
! 138: \EG @node eval_str,,, Strings
1.2 noro 139: @subsection @code{eval_str}
140: @findex eval_str
141:
142: @table @t
143: @item eval_str(@var{str})
1.3 ! noro 144: \JP :: @var{str} ($BJ8;zNs(B) $B$rI>2A$9$k(B.
! 145: \EG :: Evaluates a string @var{str}.
1.2 noro 146: @end table
147:
148: @table @var
149: @item return
1.3 ! noro 150: \JP $B%*%V%8%'%/%H(B
! 151: \EG object
1.2 noro 152: @item str
1.3 ! noro 153: \JP @b{Asir} $B$N(B parser $B$,<uM}2DG=$JJ8;zNs(B
! 154: \EG string which can be accepted by @b{Asir} parser
1.2 noro 155: @end table
156:
157: @itemize @bullet
1.3 ! noro 158: \BJP
1.2 noro 159: @item
160: @b{Asir} $B$N(B parser $B$,<uM}2DG=$JJ8;zNs$rI>2A$7$F$=$N7k2L$rJV$9(B.
161: @item
162: $BI>2A2DG=$JJ8;zNs$O(B, $B<0$rI=$9$b$N$K8B$k(B.
163: @item
164: $BO@M}E*$K$O(B @code{rtostr()} $B$N5U4X?t$H$J$k(B.
1.3 ! noro 165: \E
! 166: \BEG
! 167: @item
! 168: This function evaluates a string which can be accepted by @b{Asir} parser
! 169: and returns the result.
! 170: @item
! 171: The input string should represent an expression.
! 172: @item
! 173: This functions is the inversion function of @code{rtostr()}.
! 174: \E
1.2 noro 175: @end itemize
176:
177: @example
178: [0] eval_str("1+2");
179: 3
180: [1] fctr(eval_str(rtostr((x+y)^10)));
181: [[1,1],[x+y,10]]
182: @end example
183:
184: @table @t
1.3 ! noro 185: \JP @item $B;2>H(B
! 186: \EG @item References
1.2 noro 187: @fref{rtostr}
1.1 noro 188: @end table
189:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>