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

Annotation of OpenXM/src/asir-doc/parts/builtin/string.texi, Revision 1.6

1.6     ! noro        1: @comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/string.texi,v 1.5 2000/03/02 07:46:14 noro Exp $
1.3       noro        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.4       noro       15: * strtoascii asciitostr::
1.5       noro       16: * str_len str_chr sub_str::
1.1       noro       17: @end menu
                     18:
1.3       noro       19: \JP @node rtostr,,, $BJ8;zNs$K4X$9$k1i;;(B
                     20: \EG @node rtostr,,, Strings
1.1       noro       21: @subsection @code{rtostr}
                     22: @findex rtostr
                     23:
                     24: @table @t
                     25: @item rtostr(@var{obj})
1.3       noro       26: \JP :: @var{obj} $B$rJ8;zNs$KJQ$($k(B.
                     27: \EG :: Convert @var{obj} into a string.
1.1       noro       28: @end table
                     29:
                     30: @table @var
                     31: @item return
1.3       noro       32: \JP $BJ8;zNs(B
                     33: \EG string
1.1       noro       34: @item obj
1.3       noro       35: \JP $BG$0U(B
                     36: \EG arbitrary
1.1       noro       37: @end table
                     38:
                     39: @itemize @bullet
1.3       noro       40: \BJP
1.1       noro       41: @item
                     42: $BG$0U$N%*%V%8%'%/%H(B @var{obj} $B$rJ8;zNs$KJQ$($k(B.
                     43: @item
                     44: $B@0?t$J$I$rJ8;zNs$KJQ49$7$FJQ?tL>$H7k9g$9$k$3$H$K$h$j(B,
                     45: $BE:;zIU$-$NITDj85$r@8@.$9$k>l9g$KB?$/MQ$$$i$l$k(B.
                     46: @item
                     47: $B5U$K(B, $BJ8;zNs$rITDj85$KJQ49$9$k;~$K$O(B, @code{strtov} $B$rMQ$$$k(B.
1.3       noro       48: \E
                     49: \BEG
                     50: @item
                     51: Convert an arbitrary object @var{obj} into a string.
                     52: @item
                     53: This function is convenient to create variables with numbered
                     54: (or indexed) names by converting integers into strings and appending them
                     55: to some name strings.
                     56: @item
                     57: Use @code{strtov()} for inverse conversion from string to indeterminate.
                     58: \E
1.1       noro       59: @end itemize
                     60:
                     61: @example
                     62: [0] A=afo;
                     63: afo
                     64: [1] type(A);
                     65: 2
                     66: [2] B=rtostr(A);
                     67: afo
                     68: [3] type(B);
                     69: 7
                     70: [4] B+"1";
                     71: afo1
                     72: @end example
                     73:
                     74: @table @t
1.3       noro       75: \JP @item $B;2>H(B
                     76: \EG @item References
1.1       noro       77: @fref{strtov}, @fref{type}.
                     78: @end table
                     79:
1.3       noro       80: \JP @node strtov,,, $BJ8;zNs$K4X$9$k1i;;(B
                     81: \EG @node strtov,,, Strings
1.1       noro       82: @subsection @code{strtov}
                     83: @findex strtov
                     84:
                     85: @table @t
                     86: @item strtov(@var{str})
1.3       noro       87: \JP :: @var{str} ($BJ8;zNs(B) $B$rITDj85$KJQ$($k(B.
                     88: \EG :: Convert a string @var{str} into an indeterminate.
1.1       noro       89: @end table
                     90:
                     91: @table @var
                     92: @item return
1.3       noro       93: \JP $BITDj85(B
                     94: \EG intederminate
1.1       noro       95: @item str
1.3       noro       96: \JP $BITDj85$H$7$FJQ492DG=$JJ8;zNs(B
                     97: \EG string which is valid to constitute an indeterminate.
1.1       noro       98: @end table
                     99:
                    100: @itemize @bullet
1.3       noro      101: \BJP
1.1       noro      102: @item
                    103: $BITDj85$H$7$FJQ492DG=$JJ8;zNs$rITDj85$KJQ$($k(B.
                    104: @item
                    105: $BITDj85$H$7$FJQ492DG=$JJ8;zNs$H$O(B, $B1Q>.J8;z$G;O$^$j(B,
                    106: $B1Q;z(B, $B?t;z$*$h$S5-9f(B @code{_} $B$G:n$i$l$kJ8;zNs$G$"$k(B.
                    107: @item
                    108: @code{rtostr()} $B$HAH9g$;$F(B, $B%W%m%0%i%`Cf$G<+F0E*$KITDj85$r@8@.$7$?$$;~$K(B
                    109: $BMQ$$$i$l$k(B.
1.3       noro      110: \E
                    111: \BEG
                    112: @item
                    113: Convert a string that is valid for an indeterminate into an indeterminate
                    114: which have @var{str} as its print name.
                    115: @item
                    116: The valid string for an indeterminate is such a string that begins
                    117: with a small alphabetical letter possibly followed by any string composed
                    118: of alphabetical letters, digits or a symbol @samp{_}.
                    119: @item
                    120: Use the command to create indeterminates dynamically in programs.
                    121: \E
1.1       noro      122: @end itemize
                    123:
                    124: @example
                    125: [0] A="afo";
                    126: afo
                    127: [1] for (I=0;I<3;I++) @{B=strtov(A+rtostr(I)); print([B,type(B)]);@}
                    128: [afo0,2]
                    129: [afo1,2]
                    130: [afo2,2]
                    131: @end example
                    132:
                    133: @table @t
1.3       noro      134: \JP @item $B;2>H(B
                    135: \EG @item References
1.1       noro      136: @fref{rtostr}, @fref{type}, @fref{uc}.
1.2       noro      137: @end table
                    138:
1.3       noro      139: \JP @node eval_str,,, $BJ8;zNs$K4X$9$k1i;;(B
                    140: \EG @node eval_str,,, Strings
1.2       noro      141: @subsection @code{eval_str}
                    142: @findex eval_str
                    143:
                    144: @table @t
                    145: @item eval_str(@var{str})
1.3       noro      146: \JP :: @var{str} ($BJ8;zNs(B) $B$rI>2A$9$k(B.
                    147: \EG :: Evaluates a string @var{str}.
1.2       noro      148: @end table
                    149:
                    150: @table @var
                    151: @item return
1.3       noro      152: \JP $B%*%V%8%'%/%H(B
                    153: \EG object
1.2       noro      154: @item str
1.3       noro      155: \JP @b{Asir} $B$N(B parser $B$,<uM}2DG=$JJ8;zNs(B
                    156: \EG string which can be accepted by @b{Asir} parser
1.2       noro      157: @end table
                    158:
                    159: @itemize @bullet
1.3       noro      160: \BJP
1.2       noro      161: @item
                    162: @b{Asir} $B$N(B parser $B$,<uM}2DG=$JJ8;zNs$rI>2A$7$F$=$N7k2L$rJV$9(B.
                    163: @item
                    164: $BI>2A2DG=$JJ8;zNs$O(B, $B<0$rI=$9$b$N$K8B$k(B.
                    165: @item
                    166: $BO@M}E*$K$O(B @code{rtostr()} $B$N5U4X?t$H$J$k(B.
1.3       noro      167: \E
                    168: \BEG
                    169: @item
                    170: This function evaluates a string which can be accepted by @b{Asir} parser
                    171: and returns the result.
                    172: @item
                    173: The input string should represent an expression.
                    174: @item
                    175: This functions is the inversion function of @code{rtostr()}.
                    176: \E
1.2       noro      177: @end itemize
                    178:
                    179: @example
                    180: [0] eval_str("1+2");
                    181: 3
                    182: [1] fctr(eval_str(rtostr((x+y)^10)));
                    183: [[1,1],[x+y,10]]
                    184: @end example
                    185:
                    186: @table @t
1.3       noro      187: \JP @item $B;2>H(B
                    188: \EG @item References
1.2       noro      189: @fref{rtostr}
1.1       noro      190: @end table
                    191:
1.4       noro      192: \JP @node strtoascii asciitostr,,, $BJ8;zNs$K4X$9$k1i;;(B
                    193: \EG @node strtoascii asciitostr,,, Strings
                    194: @subsection @code{strtoascii}, @code{asciitostr}
                    195: @findex strtoascii
                    196: @findex asciitostr
                    197:
                    198: @table @t
                    199: @item strtoascii(@var{str})
                    200: \JP :: $BJ8;zNs$r%"%9%-!<%3!<%I$GI=$9(B.
                    201: \EG :: Converts a string into a sequence of ASCII codes.
                    202: @item asciitostr(@var{list})
                    203: \JP :: $B%"%9%-!<%3!<%I$NNs$rJ8;zNs$KJQ49$9$k(B.
                    204: \EG :: Converts a sequence of ASCII codes into a string.
                    205: @end table
                    206:
                    207: @table @var
                    208: @item return
                    209: \JP @code{strtoascii()}:$B%j%9%H(B; @code{asciitostr()}:$BJ8;zNs(B
                    210: \EG @code{strtoascii()}:list; @code{asciitostr()}:string
                    211: @item str
                    212: \JP $BJ8;zNs(B
                    213: \EG string
                    214: @item list
                    215: \JP 1 $B0J>e(B 256 $BL$K~$N@0?t$+$i$J$k%j%9%H(B
                    216: \EG list containing positive integers less than 256.
                    217: @end table
                    218:
                    219: @itemize @bullet
                    220: \BJP
                    221: @item
                    222: @code{strtoascii()} $B$OJ8;zNs$r@0?t$N%j%9%H$KJQ49$9$k(B. $B3F(B
                    223: $B@0?t$OJ8;zNs$N%"%9%-!<%3!<%I$rI=$9(B.
                    224: @item
                    225: @code{asciitostr()} $B$O(B @code{asciitostr()} $B$N5U4X?t$G$"$k(B.
                    226: \E
                    227: \BEG
                    228: @item
                    229: @code{strtoascii()} converts a string into a list of integers
                    230: which is a representation of the string by the ASCII code.
                    231: @item
                    232: @code{asciitostr()} is the inverse of @code{asciitostr()}.
                    233: \E
                    234: @end itemize
                    235:
                    236: @example
                    237: [0] strtoascii("abcxyz");
                    238: [97,98,99,120,121,122]
                    239: [1] asciitostr(@@);
                    240: abcxyz
                    241: [2] asciitostr([256]);
                    242: asciitostr : argument out of range
                    243: return to toplevel
1.5       noro      244: @end example
                    245:
                    246: \JP @node str_len str_chr sub_str,,, $BJ8;zNs$K4X$9$k1i;;(B
                    247: \EG @node str_len str_chr sub_str,,, Strings
                    248: @subsection @code{str_len}, @code{str_chr}, @code{sub_str}
                    249: @findex str_len
                    250: @findex str_chr
                    251: @findex sub_str
                    252:
                    253: @table @t
                    254: @item str_len(@var{str})
                    255: \JP :: $BJ8;zNs$ND9$5$rJV$9(B.
                    256: \EG :: Returns the length of a string.
                    257: @item str_chr(@var{str},@var{start},@var{c})
                    258: \JP :: $BJ8;z$,:G=i$K8=$l$k0LCV$rJV$9(B.
                    259: \EG :: Returns the position of the first occurrence of a character in a string.
                    260: @item sub_str(@var{str},@var{start},@var{end})
                    261: \JP :: $BItJ,J8;zNs$rJV$9(B.
                    262: \EG :: Returns a substring of a string.
                    263: @end table
                    264:
                    265: @table @var
                    266: @item return
                    267: \JP @code{str_len()}, @code{str_chr()}:$B@0?t(B; @code{sub_str()}:$BJ8;zNs(B
                    268: \EG @code{str_len()}, @code{str_chr()}:integer; @code{sub_str()}:string
1.6     ! noro      269: @item str c
1.5       noro      270: \JP $BJ8;zNs(B
                    271: \EG string
1.6     ! noro      272: @item start end
1.5       noro      273: \JP $BHsIi@0?t(B
                    274: \EG non-negative integer
                    275: @end table
                    276:
                    277: @itemize @bullet
                    278: \BJP
                    279: @item @code{str_len()} $B$OJ8;zNs$ND9$5$rJV$9(B.
                    280: @item @code{str_chr()} $B$O(B @var{str} $B$N(B @var{start} $BHVL\$NJ8;z$+$i%9%-%c%s$7$F(B
                    281: $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.
                    282: $B;XDj$5$l$?J8;z$,8=$l$J$$>l9g$K$O(B -1 $B$rJV$9(B.
                    283: @item @code{sub_str()} $B$O(B, @var{str} $B$N(B @var{start} $BHVL\$+$i(B @var{end} $BHVL\(B
                    284: $B$^$G$NItJ,J8;zNs$r@8@.$7JV$9(B.
                    285: \E
                    286: \BEG
                    287: @item @code{str_len()} returns the length of a string.
                    288: @item @code{str_chr()} scans a string @var{str} from the @var{start}-th
                    289: character and returns the position of the first occurrence
                    290: of the first character of a string @var{c}. Note that the top of a string
                    291: is the 0-th charater. It returns -1 if the character does not appear.
                    292: @item @code{sub_str()} generates a substring of @var{str} containing
                    293: characters from the @var{start}-th one to the @var{end}-th one.
                    294: \E
                    295: @end itemize
                    296:
                    297: @example
                    298: [185] Line="123 456 (x+y)^3";
                    299: 123 456 (x+y)^3
                    300: [186] Sp1 = str_chr(Line,0," ");
                    301: 3
                    302: [187] D0 = eval_str(sub_str(Line,0,Sp1-1));
                    303: 123
                    304: [188] Sp2 = str_chr(Line,Sp1+1," ");
                    305: 7
                    306: [189] D1 = eval_str(sub_str(Line,Sp1+1,Sp2-1));
                    307: 456
                    308: [190] C = eval_str(sub_str(Line,Sp2+1,str_len(Line)-1));
                    309: x^3+3*y*x^2+3*y^2*x+y^3
1.4       noro      310: @end example

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