Programming 275
left Syntax: left(str,n)
Return the first n characters of string str. If
or , returns str. If n == 0 returns the empty string.
Example: left("MOMOGUMBO",3) returns "MOM"
right Syntax: right(str,n)
Returns the last n characters of string str. If n <= 0, returns
empty string. If n > - dim(str), returns str
Example: right("MOMOGUMBO",5) returns
"GUMBO"
mid Syntax: mid(str,pos, [n])
Extracts n characters from string str starting at index pos.
n is optional, if not specified, extracts all the remainder of
the string.
Example: mid("MOMOGUMBO",3,5) returns
"MOGUM", mid("PUDGE",4) returns "GE"
rotate Syntax: rotate(str,n)
Permutation of characters in string str. If 0<=n<dim(str),
shifts n places to left. If -dim(str)<n<=-1, shifts n spaces to
right. If n > dim(str) or
n < -dim(str), returns str.
Examples:
rotate("12345",2) returns "34512"
rotate("12345",-1) returns "51234"
rotate("12345",6) returns "12345"
Test Commands The Test commands include both Boolean and relational
operations. Boolean and relational expressions evaluate
to true or false. A non-zero number is equivalent to true,
and a number equal to 0 is equivalent to false. Note that
in addition to real numbers, complex numbers, strings,
lists, and matrices can be compared using the relational
operators ==, NOT (or !=), and (or <> or !=). These
commands are not in the CMDS menu. They appear in
the Math menu but are listed here for convenience.