@comment $OpenXM: OpenXM/src/asir-doc/parts/builtin/string.texi,v 1.4 2000/02/07 07:11:38 noro Exp $ \BJP @node 文字列に関する演算,,, 組み込み函数 @section 文字列に関する演算 \E \BEG @node Strings,,, Built-in Function @section Strings \E @menu * rtostr:: * strtov:: * eval_str:: * strtoascii asciitostr:: @end menu \JP @node rtostr,,, 文字列に関する演算 \EG @node rtostr,,, Strings @subsection @code{rtostr} @findex rtostr @table @t @item rtostr(@var{obj}) \JP :: @var{obj} を文字列に変える. \EG :: Convert @var{obj} into a string. @end table @table @var @item return \JP 文字列 \EG string @item obj \JP 任意 \EG arbitrary @end table @itemize @bullet \BJP @item 任意のオブジェクト @var{obj} を文字列に変える. @item 整数などを文字列に変換して変数名と結合することにより, 添字付きの不定元を生成する場合に多く用いられる. @item 逆に, 文字列を不定元に変換する時には, @code{strtov} を用いる. \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 @example [0] A=afo; afo [1] type(A); 2 [2] B=rtostr(A); afo [3] type(B); 7 [4] B+"1"; afo1 @end example @table @t \JP @item 参照 \EG @item References @fref{strtov}, @fref{type}. @end table \JP @node strtov,,, 文字列に関する演算 \EG @node strtov,,, Strings @subsection @code{strtov} @findex strtov @table @t @item strtov(@var{str}) \JP :: @var{str} (文字列) を不定元に変える. \EG :: Convert a string @var{str} into an indeterminate. @end table @table @var @item return \JP 不定元 \EG intederminate @item str \JP 不定元として変換可能な文字列 \EG string which is valid to constitute an indeterminate. @end table @itemize @bullet \BJP @item 不定元として変換可能な文字列を不定元に変える. @item 不定元として変換可能な文字列とは, 英小文字で始まり, 英字, 数字および記号 @code{_} で作られる文字列である. @item @code{rtostr()} と組合せて, プログラム中で自動的に不定元を生成したい時に 用いられる. \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 @example [0] A="afo"; afo [1] for (I=0;I<3;I++) @{B=strtov(A+rtostr(I)); print([B,type(B)]);@} [afo0,2] [afo1,2] [afo2,2] @end example @table @t \JP @item 参照 \EG @item References @fref{rtostr}, @fref{type}, @fref{uc}. @end table \JP @node eval_str,,, 文字列に関する演算 \EG @node eval_str,,, Strings @subsection @code{eval_str} @findex eval_str @table @t @item eval_str(@var{str}) \JP :: @var{str} (文字列) を評価する. \EG :: Evaluates a string @var{str}. @end table @table @var @item return \JP オブジェクト \EG object @item str \JP @b{Asir} の parser が受理可能な文字列 \EG string which can be accepted by @b{Asir} parser @end table @itemize @bullet \BJP @item @b{Asir} の parser が受理可能な文字列を評価してその結果を返す. @item 評価可能な文字列は, 式を表すものに限る. @item 論理的には @code{rtostr()} の逆関数となる. \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 参照 \EG @item References @fref{rtostr} @end table \JP @node strtoascii asciitostr,,, 文字列に関する演算 \EG @node strtoascii asciitostr,,, Strings @subsection @code{strtoascii}, @code{asciitostr} @findex strtoascii @findex asciitostr @table @t @item strtoascii(@var{str}) \JP :: 文字列をアスキーコードで表す. \EG :: Converts a string into a sequence of ASCII codes. @item asciitostr(@var{list}) \JP :: アスキーコードの列を文字列に変換する. \EG :: Converts a sequence of ASCII codes into a string. @end table @table @var @item return \JP @code{strtoascii()}:リスト; @code{asciitostr()}:文字列 \EG @code{strtoascii()}:list; @code{asciitostr()}:string @item str \JP 文字列 \EG string @item list \JP 1 以上 256 未満の整数からなるリスト \EG list containing positive integers less than 256. @end table @itemize @bullet \BJP @item @code{strtoascii()} は文字列を整数のリストに変換する. 各 整数は文字列のアスキーコードを表す. @item @code{asciitostr()} は @code{asciitostr()} の逆関数である. \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