[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.10 Strings


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.10.1 rtostr

rtostr(obj)

:: Convert obj into a string.

return

string

obj

arbitrary

[0] A=afo;
afo
[1] type(A);
2
[2] B=rtostr(A); 
afo
[3] type(B);
7
[4] B+"1";
afo1
References

strtov, type.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.10.2 strtov

strtov(str)

:: Convert a string str into an indeterminate.

return

intederminate

str

string which is valid to constitute an indeterminate.

[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]
References

rtostr, type, uc.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.10.3 eval_str

eval_str(str)

:: Evaluates a string str.

return

object

str

string which can be accepted by Asir parser

[0] eval_str("1+2");
3
[1] fctr(eval_str(rtostr((x+y)^10)));
[[1,1],[x+y,10]]
References

rtostr


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.10.4 strtoascii, asciitostr

strtoascii(str)

:: Converts a string into a sequence of ASCII codes.

asciitostr(list)

:: Converts a sequence of ASCII codes into a string.

return

strtoascii():list; asciitostr():string

str

string

list

list containing positive integers less than 256.

[0] strtoascii("abcxyz");
[97,98,99,120,121,122]
[1] asciitostr(@);
abcxyz
[2] asciitostr([256]);
asciitostr : argument out of range
return to toplevel

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.10.5 str_len, str_chr, sub_str

str_len(str)

:: Returns the length of a string.

str_chr(str,start,c)

:: Returns the position of the first occurrence of a character in a string.

sub_str(str,start,end)

:: Returns a substring of a string.

return

str_len(), str_chr():integer; sub_str():string

str c

string

start end

non-negative integer

[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

[ << ] [ < ] [ Up ] [ > ] [ >> ]

This document was generated on December 22, 2024 using texi2html 5.0.