version 1.1.1.1, 1999/12/08 05:47:44 |
version 1.6, 2003/04/19 15:44:59 |
|
|
|
@comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/string.texi,v 1.5 2000/03/02 07:46:14 noro Exp $ |
|
\BJP |
@node $BJ8;zNs$K4X$9$k1i;;(B,,, $BAH$_9~$_H!?t(B |
@node $BJ8;zNs$K4X$9$k1i;;(B,,, $BAH$_9~$_H!?t(B |
@section $BJ8;zNs$K4X$9$k1i;;(B |
@section $BJ8;zNs$K4X$9$k1i;;(B |
|
\E |
|
\BEG |
|
@node Strings,,, Built-in Function |
|
@section Strings |
|
\E |
|
|
@menu |
@menu |
* rtostr:: |
* rtostr:: |
* strtov:: |
* strtov:: |
|
* eval_str:: |
|
* strtoascii asciitostr:: |
|
* str_len str_chr sub_str:: |
@end menu |
@end menu |
|
|
@node rtostr,,, $BJ8;zNs$K4X$9$k1i;;(B |
\JP @node rtostr,,, $BJ8;zNs$K4X$9$k1i;;(B |
|
\EG @node rtostr,,, Strings |
@subsection @code{rtostr} |
@subsection @code{rtostr} |
@findex rtostr |
@findex rtostr |
|
|
@table @t |
@table @t |
@item rtostr(@var{obj}) |
@item rtostr(@var{obj}) |
:: @var{obj} $B$rJ8;zNs$KJQ$($k(B. |
\JP :: @var{obj} $B$rJ8;zNs$KJQ$($k(B. |
|
\EG :: Convert @var{obj} into a string. |
@end table |
@end table |
|
|
@table @var |
@table @var |
@item return |
@item return |
$BJ8;zNs(B |
\JP $BJ8;zNs(B |
|
\EG string |
@item obj |
@item obj |
$BG$0U(B |
\JP $BG$0U(B |
|
\EG arbitrary |
@end table |
@end table |
|
|
@itemize @bullet |
@itemize @bullet |
|
\BJP |
@item |
@item |
$BG$0U$N%*%V%8%'%/%H(B @var{obj} $B$rJ8;zNs$KJQ$($k(B. |
$BG$0U$N%*%V%8%'%/%H(B @var{obj} $B$rJ8;zNs$KJQ$($k(B. |
@item |
@item |
|
|
$BE:;zIU$-$NITDj85$r@8@.$9$k>l9g$KB?$/MQ$$$i$l$k(B. |
$BE:;zIU$-$NITDj85$r@8@.$9$k>l9g$KB?$/MQ$$$i$l$k(B. |
@item |
@item |
$B5U$K(B, $BJ8;zNs$rITDj85$KJQ49$9$k;~$K$O(B, @code{strtov} $B$rMQ$$$k(B. |
$B5U$K(B, $BJ8;zNs$rITDj85$KJQ49$9$k;~$K$O(B, @code{strtov} $B$rMQ$$$k(B. |
|
\E |
|
\BEG |
|
@item |
|
Convert an arbitrary object @var{obj} into a string. |
|
@item |
|
This function is convenient to create variables with numbered |
|
(or indexed) names by converting integers into strings and appending them |
|
to some name strings. |
|
@item |
|
Use @code{strtov()} for inverse conversion from string to indeterminate. |
|
\E |
@end itemize |
@end itemize |
|
|
@example |
@example |
|
|
@end example |
@end example |
|
|
@table @t |
@table @t |
@item $B;2>H(B |
\JP @item $B;2>H(B |
|
\EG @item References |
@fref{strtov}, @fref{type}. |
@fref{strtov}, @fref{type}. |
@end table |
@end table |
|
|
@node strtov,,, $BJ8;zNs$K4X$9$k1i;;(B |
\JP @node strtov,,, $BJ8;zNs$K4X$9$k1i;;(B |
|
\EG @node strtov,,, Strings |
@subsection @code{strtov} |
@subsection @code{strtov} |
@findex strtov |
@findex strtov |
|
|
@table @t |
@table @t |
@item strtov(@var{str}) |
@item strtov(@var{str}) |
:: @var{str} ($BJ8;zNs(B) $B$rITDj85$KJQ$($k(B. |
\JP :: @var{str} ($BJ8;zNs(B) $B$rITDj85$KJQ$($k(B. |
|
\EG :: Convert a string @var{str} into an indeterminate. |
@end table |
@end table |
|
|
@table @var |
@table @var |
@item return |
@item return |
$BITDj85(B |
\JP $BITDj85(B |
|
\EG intederminate |
@item str |
@item str |
$BITDj85$H$7$FJQ492DG=$JJ8;zNs(B |
\JP $BITDj85$H$7$FJQ492DG=$JJ8;zNs(B |
|
\EG string which is valid to constitute an indeterminate. |
@end table |
@end table |
|
|
@itemize @bullet |
@itemize @bullet |
|
\BJP |
@item |
@item |
$BITDj85$H$7$FJQ492DG=$JJ8;zNs$rITDj85$KJQ$($k(B. |
$BITDj85$H$7$FJQ492DG=$JJ8;zNs$rITDj85$KJQ$($k(B. |
@item |
@item |
|
|
@item |
@item |
@code{rtostr()} $B$HAH9g$;$F(B, $B%W%m%0%i%`Cf$G<+F0E*$KITDj85$r@8@.$7$?$$;~$K(B |
@code{rtostr()} $B$HAH9g$;$F(B, $B%W%m%0%i%`Cf$G<+F0E*$KITDj85$r@8@.$7$?$$;~$K(B |
$BMQ$$$i$l$k(B. |
$BMQ$$$i$l$k(B. |
|
\E |
|
\BEG |
|
@item |
|
Convert a string that is valid for an indeterminate into an indeterminate |
|
which have @var{str} as its print name. |
|
@item |
|
The valid string for an indeterminate is such a string that begins |
|
with a small alphabetical letter possibly followed by any string composed |
|
of alphabetical letters, digits or a symbol @samp{_}. |
|
@item |
|
Use the command to create indeterminates dynamically in programs. |
|
\E |
@end itemize |
@end itemize |
|
|
@example |
@example |
|
|
@end example |
@end example |
|
|
@table @t |
@table @t |
@item $B;2>H(B |
\JP @item $B;2>H(B |
|
\EG @item References |
@fref{rtostr}, @fref{type}, @fref{uc}. |
@fref{rtostr}, @fref{type}, @fref{uc}. |
@end table |
@end table |
|
|
|
\JP @node eval_str,,, $BJ8;zNs$K4X$9$k1i;;(B |
|
\EG @node eval_str,,, Strings |
|
@subsection @code{eval_str} |
|
@findex eval_str |
|
|
|
@table @t |
|
@item eval_str(@var{str}) |
|
\JP :: @var{str} ($BJ8;zNs(B) $B$rI>2A$9$k(B. |
|
\EG :: Evaluates a string @var{str}. |
|
@end table |
|
|
|
@table @var |
|
@item return |
|
\JP $B%*%V%8%'%/%H(B |
|
\EG object |
|
@item str |
|
\JP @b{Asir} $B$N(B parser $B$,<uM}2DG=$JJ8;zNs(B |
|
\EG string which can be accepted by @b{Asir} parser |
|
@end table |
|
|
|
@itemize @bullet |
|
\BJP |
|
@item |
|
@b{Asir} $B$N(B parser $B$,<uM}2DG=$JJ8;zNs$rI>2A$7$F$=$N7k2L$rJV$9(B. |
|
@item |
|
$BI>2A2DG=$JJ8;zNs$O(B, $B<0$rI=$9$b$N$K8B$k(B. |
|
@item |
|
$BO@M}E*$K$O(B @code{rtostr()} $B$N5U4X?t$H$J$k(B. |
|
\E |
|
\BEG |
|
@item |
|
This function evaluates a string which can be accepted by @b{Asir} parser |
|
and returns the result. |
|
@item |
|
The input string should represent an expression. |
|
@item |
|
This functions is the inversion function of @code{rtostr()}. |
|
\E |
|
@end itemize |
|
|
|
@example |
|
[0] eval_str("1+2"); |
|
3 |
|
[1] fctr(eval_str(rtostr((x+y)^10))); |
|
[[1,1],[x+y,10]] |
|
@end example |
|
|
|
@table @t |
|
\JP @item $B;2>H(B |
|
\EG @item References |
|
@fref{rtostr} |
|
@end table |
|
|
|
\JP @node strtoascii asciitostr,,, $BJ8;zNs$K4X$9$k1i;;(B |
|
\EG @node strtoascii asciitostr,,, Strings |
|
@subsection @code{strtoascii}, @code{asciitostr} |
|
@findex strtoascii |
|
@findex asciitostr |
|
|
|
@table @t |
|
@item strtoascii(@var{str}) |
|
\JP :: $BJ8;zNs$r%"%9%-!<%3!<%I$GI=$9(B. |
|
\EG :: Converts a string into a sequence of ASCII codes. |
|
@item asciitostr(@var{list}) |
|
\JP :: $B%"%9%-!<%3!<%I$NNs$rJ8;zNs$KJQ49$9$k(B. |
|
\EG :: Converts a sequence of ASCII codes into a string. |
|
@end table |
|
|
|
@table @var |
|
@item return |
|
\JP @code{strtoascii()}:$B%j%9%H(B; @code{asciitostr()}:$BJ8;zNs(B |
|
\EG @code{strtoascii()}:list; @code{asciitostr()}:string |
|
@item str |
|
\JP $BJ8;zNs(B |
|
\EG string |
|
@item list |
|
\JP 1 $B0J>e(B 256 $BL$K~$N@0?t$+$i$J$k%j%9%H(B |
|
\EG list containing positive integers less than 256. |
|
@end table |
|
|
|
@itemize @bullet |
|
\BJP |
|
@item |
|
@code{strtoascii()} $B$OJ8;zNs$r@0?t$N%j%9%H$KJQ49$9$k(B. $B3F(B |
|
$B@0?t$OJ8;zNs$N%"%9%-!<%3!<%I$rI=$9(B. |
|
@item |
|
@code{asciitostr()} $B$O(B @code{asciitostr()} $B$N5U4X?t$G$"$k(B. |
|
\E |
|
\BEG |
|
@item |
|
@code{strtoascii()} converts a string into a list of integers |
|
which is a representation of the string by the ASCII code. |
|
@item |
|
@code{asciitostr()} is the inverse of @code{asciitostr()}. |
|
\E |
|
@end itemize |
|
|
|
@example |
|
[0] strtoascii("abcxyz"); |
|
[97,98,99,120,121,122] |
|
[1] asciitostr(@@); |
|
abcxyz |
|
[2] asciitostr([256]); |
|
asciitostr : argument out of range |
|
return to toplevel |
|
@end example |
|
|
|
\JP @node str_len str_chr sub_str,,, $BJ8;zNs$K4X$9$k1i;;(B |
|
\EG @node str_len str_chr sub_str,,, Strings |
|
@subsection @code{str_len}, @code{str_chr}, @code{sub_str} |
|
@findex str_len |
|
@findex str_chr |
|
@findex sub_str |
|
|
|
@table @t |
|
@item str_len(@var{str}) |
|
\JP :: $BJ8;zNs$ND9$5$rJV$9(B. |
|
\EG :: Returns the length of a string. |
|
@item str_chr(@var{str},@var{start},@var{c}) |
|
\JP :: $BJ8;z$,:G=i$K8=$l$k0LCV$rJV$9(B. |
|
\EG :: Returns the position of the first occurrence of a character in a string. |
|
@item sub_str(@var{str},@var{start},@var{end}) |
|
\JP :: $BItJ,J8;zNs$rJV$9(B. |
|
\EG :: Returns a substring of a string. |
|
@end table |
|
|
|
@table @var |
|
@item return |
|
\JP @code{str_len()}, @code{str_chr()}:$B@0?t(B; @code{sub_str()}:$BJ8;zNs(B |
|
\EG @code{str_len()}, @code{str_chr()}:integer; @code{sub_str()}:string |
|
@item str c |
|
\JP $BJ8;zNs(B |
|
\EG string |
|
@item start end |
|
\JP $BHsIi@0?t(B |
|
\EG non-negative integer |
|
@end table |
|
|
|
@itemize @bullet |
|
\BJP |
|
@item @code{str_len()} $B$OJ8;zNs$ND9$5$rJV$9(B. |
|
@item @code{str_chr()} $B$O(B @var{str} $B$N(B @var{start} $BHVL\$NJ8;z$+$i%9%-%c%s$7$F(B |
|
$B:G=i$K(B @var{c} $B$N:G=i$NJ8;z$,8=$l$?0LCV$rJV$9(B. $BJ8;zNs$N@hF,$O(B 0 $BHVL\$H$9$k(B. |
|
$B;XDj$5$l$?J8;z$,8=$l$J$$>l9g$K$O(B -1 $B$rJV$9(B. |
|
@item @code{sub_str()} $B$O(B, @var{str} $B$N(B @var{start} $BHVL\$+$i(B @var{end} $BHVL\(B |
|
$B$^$G$NItJ,J8;zNs$r@8@.$7JV$9(B. |
|
\E |
|
\BEG |
|
@item @code{str_len()} returns the length of a string. |
|
@item @code{str_chr()} scans a string @var{str} from the @var{start}-th |
|
character and returns the position of the first occurrence |
|
of the first character of a string @var{c}. Note that the top of a string |
|
is the 0-th charater. It returns -1 if the character does not appear. |
|
@item @code{sub_str()} generates a substring of @var{str} containing |
|
characters from the @var{start}-th one to the @var{end}-th one. |
|
\E |
|
@end itemize |
|
|
|
@example |
|
[185] Line="123 456 (x+y)^3"; |
|
123 456 (x+y)^3 |
|
[186] Sp1 = str_chr(Line,0," "); |
|
3 |
|
[187] D0 = eval_str(sub_str(Line,0,Sp1-1)); |
|
123 |
|
[188] Sp2 = str_chr(Line,Sp1+1," "); |
|
7 |
|
[189] D1 = eval_str(sub_str(Line,Sp1+1,Sp2-1)); |
|
456 |
|
[190] C = eval_str(sub_str(Line,Sp2+1,str_len(Line)-1)); |
|
x^3+3*y*x^2+3*y^2*x+y^3 |
|
@end example |