cat( a, b, c, ... )
a, b, c, ...
The cat function is commonly used to concatenate strings and names together. The arguments are concatenated to form either a string, a name, or an object of type `||` .
The type of the result returned by cat will be `||` when one or more of the arguments are of type '||' or type 'function'. When the arguments contain an integer or character range, a sequence will be returned. When trailing arguments are of type 'indexed', the base name will be concatenated. In all other cases the argument will be turned into a string or name. See the examples later.
Note that if the result of cat is a name, then it is in fact a global name, even though there might be a local variable of the same name currently active.
To form a sequence of names (or strings), specify a symbol (or string) as the first argument, then one or more integer ranges as the subsequent arguments. Maple returns the sequence of names (or strings) formed by concatenating the symbol (or string) with the integers produced by iterating over the ranges.
When called with no arguments, or with arguments that evaluate to NULL, cat returns the empty name, ``.
The cat command is thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
The type (name or string) of the result depends on the type of the left-hand operand.
Use an empty name or string as the leading argument to force the return type to be what you want.
Other types will be converted to form part of the name or string.
cat⁡a = ,2.5
a = 2.5
Uneval quotes will suppress evaluation causing the named variable to be part of the result instead of its assigned value.
l ≔ left:
r ≔ right:
Multiple arguments can be concatenated together to form messages. See sprintf for more control over the formatting of numbers.
i ≔ 5
cat⁡The value of i is ,i,.
The value of i is 5.
Functions are not converted to strings, rather || structures are returned.
Uneval quotes are needed to prevent execution when using a function as an argument to cat.
f := proc() local a, b; a,b; end proc:
When leading arguments appear before an indexed name, the concatenation is based on the name part, excluding the index.
Arguments that follow an indexed name do not treat the index specially.
Indexed variables that are not names are not treated specially.
Be careful to note what is part of the name and what is not. The following is entirely a name, not an indexed object:
This example shows how cat can work with a sequence of arguments; in this case interleaving a colon character between words.
tr := proc(s::string,src::string,dst::string)
cat( op( map( x -> `if`( x = src, dst, x ), [ seq( i, i = s ) ] ) ) );
Warning, `i` is implicitly declared local to procedure `tr`
These examples illustrate the use of ranges to produce sequences of names. The range endpoints must be integers or single-character strings.
The following shows how to make global assignments from within procedures. It illustrates the fact that only global names are returned by cat.
gassign := proc(n::name,e::anything)
g := proc()
a := 5;
gassign( 'a', 2 );
The cat command was updated in Maple 2015.
Download Help Document
What kind of issue would you like to report? (Optional)