up previous next
CoCoA offers only a few operations on strings: length, concatenation,
comparison, substring containment and indexing.
/**/ str := "Hello" + "World!"; --> string concatenation
/**/ Print str;
HelloWorld!
/**/ len(str); --> length in characters
11
/**/ "Abc" < str; --> lexicographical comparison
true
/**/ str[1]; --> character indexing, indexes start from 1
H
|
The operator
IsIn
can be used to test if one string is
a substring of another.
/**/ mesg := "Banana";
/**/ "ana" IsIn mesg;
true
/**/ "Ana" IsIn mesg; --> substring must be an exact match
false
|